Recolors the chart's own price bars or candles, evaluated per bar.
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
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)) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| color | series color | required | Candle color, evaluated per bar. na keeps the default color. |
| offset | simple int | 0 | Shifts the coloring by this many bars; negative moves it into the past. |
| editable | input bool | true | Accepted for compatibility and ignored. |
| show_last | input int | na | Accepted for compatibility and ignored. |
| title | const string | "" | Name shown in the Settings dialog. |
| display | input plot_simple_display | display. | Where 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
//@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