Sidechair

line.set_y2()

Browse the reference

Moves only the ending price of a line, up or down.

Try it in the editor

The left end stays, so the line tilts around its first point. Feeding it a series such as close each bar keeps the right end on that series.

A horizontal line turns sloped the moment the two prices differ, and a ray keeps the new slope past the second point.

Syntax

Pine Script
line.set_y2(id: series line, y: series int/float) -> void
line.set_y2(y: series int/float) -> void

Arguments

NameTypeDefaultDescription
idseries linerequiredThe line whose second price changes; the first point does not move.
yseries int/floatrequiredNew price for the second point, in chart price units. Pass a series such as close to make the right end follow it.

Returns

Nothing.

Example

Pine ScriptSlope a ray from the open by ATROpen in editor
//@version=6
indicator("line.set_y2: ATR slope", overlay = true)
a = ta.atr(10)
var line ray = na
if timeframe.change("D")
    ray := line.new(bar_index, open, bar_index + 10, open, extend = extend.right, color = color.teal)
line.set_y2(ray, line.get_y1(ray) + a)

See also

Runs on Sidechair