Marks bars with a symbol such as a triangle, label or cross, drawn where a condition is true or at an absolute price.
plotshape draws a shape on each bar where series is true or non-zero. For the default placements the shape sits above or below the bar; with location.absolute it sits at the series value itself.
Style, location, size and title come from the first bar the call runs on. Color and text color can change on every bar. The shape styles are the shape.* constants: arrowup, arrowdown, circle, cross, diamond, flag, labeldown, labelup, square, triangledown, triangleup and xcross.
Syntax
plotshape(series: series int/float/bool, title: const string (optional), style: input string (optional), location: input string (optional), color: series color (optional), offset: simple int (optional), text: const string (optional), textcolor: series color (optional), editable: input bool (optional), size: const string (optional), show_last: input int (optional), display: input plot_display (optional), format: input string (optional), precision: input int (optional), force_overlay: const bool (optional)) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| series | series int/ | required | A bool or number. Where it is true or non-zero the shape is drawn. With location.absolute it is the price level. |
| title | const string | "Shape" | Name shown in the legend and Data Window. |
| style | input string | shape. | Shape drawn, a shape.* constant. |
| location | input string | location. | Placement, a location.* constant: abovebar, belowbar, top, bottom or absolute. |
| color | series color | #2962FF | Shape color, evaluated per bar. |
| offset | simple int | 0 | Shifts the shapes by this many bars; negative moves them into the past. |
| text | const string | "" | Text drawn with each shape. |
| textcolor | series color | na | Color of the text, evaluated per bar. |
| editable | input bool | true | Accepted for compatibility and ignored. |
| size | const string | size. | Shape size, a size.* constant: auto, tiny, small, normal, large or huge. |
| show_last | input int | na | Accepted for compatibility and ignored. |
| display | input plot_display | display. | Where the shapes are shown. display.none hides them from the chart. |
| format | input string | format. | Accepted for compatibility and ignored. |
| precision | input int | na | Accepted for compatibility and ignored. |
| force_overlay | const bool | false | When true, draws on the main chart pane even if the script runs in its own pane. |
Returns
Nothing.
Remarks
- On Sidechair: show_last, format and precision are accepted and ignored. In a pane of its own, abovebar and belowbar place shapes at the top and bottom edge of the pane, because that pane has no bars of price to sit on.
- A series that is na or 0 draws nothing, so a numeric series such as a count marks every bar where it is non-zero.
Example
//@version=6
indicator("Shape markers", overlay = true)
up = ta.crossover(close, ta.sma(close, 20))
down = ta.crossunder(close, ta.sma(close, 20))
plotshape(up, "Up", shape.triangleup, location.belowbar, color.green, size = size.small)
plotshape(down, "Down", shape.triangledown, location.abovebar, color.red, size = size.small)See also
Runs on Sidechair