Sidechair

barcolor()

Browse the reference

Recolors the chart's own price bars or candles, evaluated per bar.

Try it in the editor

barcolor sets the color of the main chart's candle or bar for each bar where color is not na. Bars where color is na keep their normal color.

It always acts on the price chart, regardless of the pane the script runs in. The body, wick and border take the one color.

Syntax

Pine Script
barcolor(color: series color, offset: simple int (optional), editable: input bool (optional), show_last: input int (optional), title: const string (optional), display: input plot_simple_display (optional)) -> void

Arguments

NameTypeDefaultDescription
colorseries colorrequiredCandle color, evaluated per bar. na keeps the default color.
offsetsimple int0Shifts the coloring by this many bars; negative moves it into the past.
editableinput booltrueAccepted for compatibility and ignored.
show_lastinput intnaAccepted for compatibility and ignored.
titleconst string""Name shown in the Settings dialog.
displayinput plot_simple_displaydisplay.allWhere the coloring is shown. display.none turns it off.

Returns

Nothing.

Remarks

  • On Sidechair: the chart's candles are redrawn in your colors over the originals, and only the first barcolor call in a script is applied.
  • Combine it with a trend filter to paint candles by regime, for example barcolor(close > ta.ema(close, 50) ? color.lime : color.red).

Example

Pine ScriptPaint candles by RSIOpen in editor
//@version=6
indicator("RSI candles", overlay = true)
r = ta.rsi(close, 14)
barcolor(r > 70 ? color.red : r < 30 ? color.green : na)
plot(r > 70 ? close : na, "Overbought", color = color.red, style = plot.style_circles)

See also

Runs on Sidechair