Sidechair

label.set_color()

Browse the reference

Changes the fill color of a label's bubble or marker.

Try it in the editor

Only the background changes; the text color is set with label.set_textcolor(). Use color.new(c, transparency) for a see-through fill.

Because a label holds one color at a time, a script that recolors it every bar shows only the latest. A gradient such as color.from_gradient() turns the fill into a readout of a value.

Syntax

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

Arguments

NameTypeDefaultDescription
idseries labelrequiredThe label whose fill changes. Text, text color and position are untouched.
colorseries colorrequiredThe new fill, for instance color.green or color.new(color.red, 40). na removes the fill and leaves only the text.

Returns

Nothing.

Remarks

  • On Sidechair: a fill color of na draws the label without a background, leaving only the text, and a shape style with a na fill draws no marker.

Example

Pine ScriptFill shaded from red to green by RSIOpen in editor
//@version=6
indicator("label.set_color: RSI gradient", overlay = true)
var label l = label.new(bar_index, high, "RSI")
r = ta.rsi(close, 14)
label.set_xy(l, bar_index, high)
label.set_text(l, "RSI " + str.tostring(r, "#"))
label.set_color(l, color.from_gradient(r, 30, 70, color.red, color.green))

See also

Runs on Sidechair