Sidechair

label.get_y()

Browse the reference

Returns the price a label was given, which is the level it points at when the label sits at a price.

Try it in the editor

It gives the y value stored in the label. For a label pinned with yloc.abovebar or yloc.belowbar the stored value is whatever was passed, even though the label is drawn off the bar.

Read it back to compare a later price against the level at which the label was placed, as a breakout test against a labelled level.

Syntax

Pine Script
label.get_y(id: series label) -> series float
label.get_y() -> series float

Arguments

NameTypeDefaultDescription
idseries labelrequiredThe label whose price is read. The stored y is returned even for labels pinned above or below their bar.

Returns

series float: The label's y coordinate.

Remarks

  • On Sidechair: a na label gives na, and a label created with y = na and yloc.abovebar returns na as well.

Example

Pine ScriptFlag a close back above a labelled levelOpen in editor
//@version=6
indicator("label.get_y: reclaim", overlay = true)
var label lvl = na
if bar_index % 40 == 0
    lvl := label.new(bar_index, high, "level", style = label.style_label_left, color = color.gray)
if not na(lvl) and ta.crossover(close, label.get_y(lvl))
    label.new(bar_index, low, "reclaim", style = label.style_label_up, color = color.green)

See also

Runs on Sidechair