Sidechair

label.set_textcolor()

Browse the reference

Changes the color of a label's text without touching its fill.

Try it in the editor

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

Pine Script
label.set_textcolor(id: series label, textcolor: series color) -> void
label.set_textcolor(textcolor: series color) -> void

Arguments

NameTypeDefaultDescription
idseries labelrequiredThe label whose text color changes. The fill and the words stay the same.
textcolorseries colorrequiredThe 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_none and label.style_text_outline a na text color falls back to the fill color.

Example

Pine ScriptGreen or red text with no bubbleOpen in editor
//@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