barcolor

Recolours the chart’s own price bars. It draws no value of its own. To colour only some bars, vary the colour rather than the call: the colour argument is series-form, while the call has to stay at the top level. Note that every argument here is optional, color included.

barcolor(series color color, const string title, input int offset) → void
ParameterTypeRequiredDescription
colorseries colornoThe colour applied to the bars. Series-form, so it may differ on every bar. Optional.
titleconst stringnoThe name of the colouring. Const-form.
offsetinput intnoShifts the colouring along the chart. Input-form, so it cannot change from bar to bar.

Returns void — void.

indicator("Colour the bars")
plot(close)
barcolor(close > open ? color.green : color.red, title = "Bars")

See also bars and background

Part of the function index.

Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.
Upgrade