Replaces the words in a label, leaving its position, colors and style as they were.
Create the label once with var and call label.set_text() on later bars, with str.tostring() or str.format() turning live numbers into words. The bubble resizes to fit the new text.
Write \n inside the string to start a new line. An empty string leaves the shape with no text, which is how a label is blanked without deleting it.
Syntax
label.set_text(id: series label, text: series string) -> void
label.set_text(text: series string) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series label | required | The label whose words are replaced. Position, colors, style and size stay as they are. |
| text | series string | required | The new text. \n starts a new line; an empty string or na leaves the label with no words. |
Returns
Nothing.
Remarks
- On Sidechair: na is stored as an empty string, text is drawn line by line with no wrapping, and a very long line widens the bubble instead of folding.
Example
//@version=6
indicator("label.set_text: percent move", overlay = true)
var label tag = label.new(bar_index, high, "")
chg = (close / close[1] - 1) * 100
label.set_xy(tag, bar_index, high)
label.set_text(tag, (chg >= 0 ? "+" : "") + str.tostring(chg, "#.##") + "%")See also
Runs on Sidechair