barcolor(color, offset?, editable?, title?, display?)
isBullMarubozu = close == high and open == low
isBearMarubozu = close == low and open == high
barcolor(isBullMarubozu ? color.lime : isBearMarubozu ? color.red : na,
title="Marubozu")
- Returns from this call stack per bar — each bar paints independently.
offsetshifts the painted barnpositions left/right.
When to use it
- Highlighting bars that match a pattern (engulfings, outside bars, high-volume candles).
- Showing a long/short regime by colouring every bar that qualifies.
- Painting a "quality" overlay over a transparent base series.
Use bgcolor() instead when you want a tint behind the whole bar area rather than a colour on the candle itself.
Translucency
A translucent barcolor() blends with the pane background, not with the original candle colour — the override repaints the body from scratch over the pane background. If you need the original candle's hue to show through, use bgcolor() instead.
Multi-condition example
avgBody = ta.sma(math.abs(close - open), 20)
upBig = close > open and (close - open) > 2 * avgBody
dnBig = close < open and (open - close) > 2 * avgBody
inside = high <= high[1] and low >= low[1]
barcolor(upBig ? color.lime :
dnBig ? color.red :
inside ? color.gray : na,
title="Pattern bar")
See also
- Backgrounds
- Colors
- Bar plotting —
plotcandlefor custom candles