Sidechair

line.get_y1()

Browse the reference

Returns the price stored for the first end point of a line.

Try it in the editor

It reads back what line.new(), line.set_y1() or line.set_xy1() last stored, in price units. Use it to compare the start of a drawn level with the current price without keeping a separate variable.

line.get_price() at the first x gives the same number unless the line is vertical. With a na id the result is na.

Syntax

Pine Script
line.get_y1(id: series line) -> series float
line.get_y1() -> series float

Arguments

NameTypeDefaultDescription
idseries linerequiredThe line to read the first point's price from.

Returns

series float: The y coordinate of the first point.

Example

Pine ScriptPercent move since the session open lineOpen in editor
//@version=6
indicator("line.get_y1: percent from anchor", overlay = false)
var line ln = na
if timeframe.change("D")
    ln := line.new(bar_index, open, bar_index + 1, open, extend = extend.right)
plot(na(ln) ? na : (close / line.get_y1(ln) - 1) * 100, "Percent from open")

See also

Runs on Sidechair