Changes the color of the text inside a box without touching its fill or outline.
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
box.set_text_color(id: series box, text_color: series color) -> void
box.set_text_color(text_color: series color) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series box | required | The box whose text color changes. |
| text_color | series color | required | New 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
//@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