Draws OHLC bars from four series for open, high, low and close, colored per bar.
plotbar draws a bar with a left tick for the open, a right tick for the close and a vertical line from low to high, from the four series you pass. Use it to show derived prices or another symbol as bars.
The color argument can change per bar. A bar with an na in any of its four values is skipped.
Syntax
plotbar(open: series int/float, high: series int/float, low: series int/float, close: series int/float, title: const string (optional), color: series color (optional), editable: input bool (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 |
|---|---|---|---|
| open | series int/ | required | Series for the bar open, drawn as a tick on the left. |
| high | series int/ | required | Series for the top of each bar, for example the high or a smoothed version of it. |
| low | series int/ | required | Series for the bottom of each bar, for example the low or a smoothed version of it. |
| close | series int/ | required | Series for the bar close, drawn as a tick on the right. |
| title | const string | "Bar" | Name shown in the legend and Data Window. |
| color | series color | na | Bar color, evaluated per bar. |
| editable | input bool | true | Accepted for compatibility and ignored. |
| show_last | input int | na | Accepted for compatibility and ignored. |
| display | input plot_display | display. | Where the bars are shown. display.none hides them. |
| 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: color has no default; pass one explicitly so the bars are visible.
Example
//@version=6
indicator("Smoothed OHLC bars", overlay = true)
o = ta.sma(open, 5)
h = ta.sma(high, 5)
l = ta.sma(low, 5)
c = ta.sma(close, 5)
plotbar(o, h, l, c, "Smoothed", c >= o ? color.green : color.red)See also
Runs on Sidechair