Sidechair

box.set_bgcolor()

Browse the reference

Changes the fill color of a box, or removes the fill when na is passed.

Try it in the editor

Only the interior changes; the outline keeps its color. A transparency from color.new(c, 85) tints the zone while price stays readable.

Recolor a zone when it is broken or retested, so the chart shows which zones are still live.

Syntax

Pine Script
box.set_bgcolor(id: series box, color: series color) -> void
box.set_bgcolor(color: series color) -> void

Arguments

NameTypeDefaultDescription
idseries boxrequiredThe box whose fill color changes.
colorseries colorrequiredNew fill color. Use color.new(c, 85) for a see-through tint; na removes the fill and leaves the outline.

Returns

Nothing.

Remarks

  • On Sidechair: the fill is painted above the candles, so an opaque color hides them. na leaves only the outline and the text.

Example

Pine ScriptTint green on up bars, red on down barsOpen in editor
//@version=6
indicator("box.set_bgcolor: tint", overlay = true)
var box z = box.new(bar_index, high, bar_index + 1, low)
box.set_right(z, bar_index)
box.set_bgcolor(z, close >= open ? color.new(color.green, 88) : color.new(color.red, 88))

See also

Runs on Sidechair