Changes the color of a label's text without touching its fill.
The fill is untouched. Pick a text color with enough contrast against the label color, for example white text on color.blue or black on color.yellow.
On a label with label.style_none there is no fill, so textcolor is the only color the label has. That makes it the way to show colored words with no bubble.
Syntax
label.set_textcolor(id: series label, textcolor: series color) -> void
label.set_textcolor(textcolor: series color) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series label | required | The label whose text color changes. The fill and the words stay the same. |
| textcolor | series color | required | The new text color. Choose one that contrasts with the fill; na is drawn white on Sidechair. |
Returns
Nothing.
Remarks
- On Sidechair: the default text color is white, a na text color is drawn white too, and on
label.style_noneandlabel.style_text_outlinea na text color falls back to the fill color.
Example
//@version=6
indicator("label.set_textcolor: bare text", overlay = true)
var label t = label.new(bar_index, high, "", style = label.style_none)
label.set_xy(t, bar_index, high)
label.set_text(t, str.tostring(close - open, "#.##"))
label.set_textcolor(t, close >= open ? color.green : color.red)See also
Runs on Sidechair