Sidechair

label.set_text()

Browse the reference

Replaces the words in a label, leaving its position, colors and style as they were.

Try it in the editor

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

Pine Script
label.set_text(id: series label, text: series string) -> void
label.set_text(text: series string) -> void

Arguments

NameTypeDefaultDescription
idseries labelrequiredThe label whose words are replaced. Position, colors, style and size stay as they are.
textseries stringrequiredThe 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

Pine ScriptSigned percent change as the label textOpen in editor
//@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