Sidechair

box.set_text_color()

Browse the reference

Changes the color of the text inside a box without touching its fill or outline.

Try it in the editor

Choose a text color that contrasts with the fill once its transparency is applied.

Black is the default and disappears on a dark chart, so a light color is the usual choice there. Switching the color by condition lets a zone label double as a status flag.

Syntax

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

Arguments

NameTypeDefaultDescription
idseries boxrequiredThe box whose text color changes.
text_colorseries colorrequiredNew color of the text. A new box starts with black, which vanishes on dark fills, so choose a light color there.

Returns

Nothing.

Remarks

  • On Sidechair: na gives white text rather than hiding the text.

Example

Pine ScriptGreen text after an up bar, red after a down barOpen in editor
//@version=6
indicator("box.set_text_color: direction", overlay = true)
var box z = box.new(bar_index, high, bar_index + 1, low, bgcolor = color.new(color.gray, 70), text = "Zone")
box.set_right(z, bar_index)
box.set_text_color(z, close >= open ? color.green : color.red)

See also

Runs on Sidechair