Skip to content

plotshape() - Pine Script Function

plotshape() draws pre-defined glyphs—triangles, flags, labels, arrows—whenever a condition evaluates to true. It is a versatile alternative to plotchar() when you prefer consistent iconography or need text labels anchored to bars.

The `series` argument is treated as boolean for all locations except location.absolute. Use `location.absolute` when you need to position shapes at a specific price value.

plotshape(series, title, style, location, color, offset, text, textcolor, editable, size, show_last, display, format, precision, force_overlay) → void
NameTypeDescription
seriesseries int/float/boolDetermines whether a shape is drawn on each bar.
styleinput shape (optional)Glyph to draw (e.g., shape.triangleup, shape.labeldown). Defaults to shape.xcross.
locationinput location (optional)Placement relative to the bar (location.abovebar, location.belowbar, location.absolute, etc.).
colorseries color (optional)Fill color for the shape.
textconst string (optional)Optional caption displayed inside label-style shapes or on hover.
sizeconst size (optional)Glyph size ranging from size.tiny to size.huge.
offsetsimple int (optional)Horizontal shift in bars.

Other optional arguments (title, textcolor, editable, show_last, display, format, precision, force_overlay) mirror plot() defaults.

  • Shapes are hidden on bars where series evaluates to na.
  • Label styles such as shape.labelup and shape.labeldown accept multiline text via \n.
  • Combine plotshape() with display=display.none to generate handles for fill() or for toggling visibility through script inputs.
//@version=5
indicator("plotshape() breakouts", overlay=true)
length = input.int(20, "Range lookback", minval=2)
upper = ta.highest(high, length)
lower = ta.lowest(low, length)
breakoutUp = ta.cross(close, upper)
breakoutDn = ta.cross(lower, close)
plotshape(breakoutUp,
title="Breakout up",
style=shape.triangleup,
location=location.abovebar,
color=color.new(color.green, 0),
size=size.small,
text="Range breakout")
plotshape(breakoutDn,
title="Breakout down",
style=shape.triangledown,
location=location.belowbar,
color=color.new(color.red, 0),
size=size.small,
text="Range breakdown")