Returns the price a label was given, which is the level it points at when the label sits at a price.
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
label.get_y(id: series label) -> series float
label.get_y() -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series label | required | The 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.abovebarreturns na as well.
Example
//@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