Changes the fill color of a label's bubble or marker.
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
label.set_color(id: series label, color: series color) -> void
label.set_color(color: series color) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series label | required | The label whose fill changes. Text, text color and position are untouched. |
| color | series color | required | The 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
//@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