Sidechair

label

Browse the reference

The type of a text marker anchored to a bar and a price, created with label.new().

Try it in the editor

A label variable holds a reference to one label drawn on the chart. Declare it as label tag = na, or let label.new() decide the type: var tag = label.new(bar_index, high, "start").

Every label carries a position (x and y), text, a color, a style that sets its shape and pointer, a text color and size, and an optional tooltip. Each of those has a label.set_* function and, for position and text, a label.get_* function.

A label variable is a handle, not the drawing. label b = a makes two names for one label, so an edit through b shows through a. Call label.copy() when you need a second, independent label.

Remarks

  • A script keeps up to 50 labels by default. max_labels_count in indicator() raises that to at most 500, and when the limit is passed the oldest label is removed.
  • label.all lists the labels the script has drawn.
  • On Sidechair: label.set_* and label.get_* calls on a label that is na change nothing and return na, so a lazily created label needs no guard around each call.

Example

Pine ScriptOne label that follows the last barOpen in editor
//@version=6
indicator("label type: follower", overlay = true)
var label tag = na
if barstate.islast
    if na(tag)
        tag := label.new(bar_index, high, "last", style = label.style_label_down)
    else
        label.set_xy(tag, bar_index, high)
        label.set_text(tag, "last: " + str.tostring(close))

See also

Runs on Sidechair