Bar Coloring
The barcolor() function is used to color bars on the main chart, regardless of whether the script is running in the main chart pane or in a separate pane.
The function’s signature is as follows:
barcolor(color, offset) → voidThe coloring can be conditional since the color parameter accepts “series color” arguments.
The script below demonstrates how to render inside and outside bars in different colors:

indicator("barcolor example", overlay = true)
isUp = close > open
isDown = close <= open
isOutsideUp = high > high[1] and low < low[1] and isUp
isOutsideDown = high > high[1] and low < low[1] and isDown
isInside = high < high[1] and low > low[1]
barcolor(isInside ? color.yellow : isOutsideUp ? color.aqua : isOutsideDown ? color.purple : na)Note:
- The
navalue leaves bars unchanged. - In the
barcolor()call, embedded?:ternary operator expressions are used to select the color.