Sidechair

plotbar()

Browse the reference

Draws OHLC bars from four series for open, high, low and close, colored per bar.

Try it in the editor

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

Pine Script
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)) -> void

Arguments

NameTypeDefaultDescription
openseries int/floatrequiredSeries for the bar open, drawn as a tick on the left.
highseries int/floatrequiredSeries for the top of each bar, for example the high or a smoothed version of it.
lowseries int/floatrequiredSeries for the bottom of each bar, for example the low or a smoothed version of it.
closeseries int/floatrequiredSeries for the bar close, drawn as a tick on the right.
titleconst string"Bar"Name shown in the legend and Data Window.
colorseries colornaBar color, evaluated per bar.
editableinput booltrueAccepted for compatibility and ignored.
show_lastinput intnaAccepted for compatibility and ignored.
displayinput plot_displaydisplay.allWhere the bars are shown. display.none hides them.
formatinput stringformat.inheritAccepted for compatibility and ignored.
precisioninput intnaAccepted for compatibility and ignored.
force_overlayconst boolfalseWhen 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

Pine ScriptMoving-average barsOpen in editor
//@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