Sidechair

line.set_xy1()

Browse the reference

Relocates the start of a line to a new bar and price in one call.

Try it in the editor

It replaces a line.set_x1() plus line.set_y1() pair. Use it when an anchor jumps to a new pivot, so the whole start moves and the other end stays.

The other end is untouched, so the slope and any extension change with the jump. A na line is left alone.

Syntax

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

Arguments

NameTypeDefaultDescription
idseries linerequiredThe line whose first point jumps to a new bar and price.
xseries intrequiredBar index, or millisecond timestamp on a bar_time line, of the new first point.
yseries int/floatrequiredPrice of the new first point, in chart price units.

Returns

Nothing.

Example

Pine ScriptRe-anchor the start on each new pivot lowOpen in editor
//@version=6
indicator("line.set_xy1: re-anchor", overlay = true)
pl = ta.pivotlow(low, 5, 5)
var line ln = line.new(bar_index, close, bar_index + 1, close, extend = extend.right)
if not na(pl)
    line.set_xy1(ln, bar_index - 5, pl)
line.set_xy2(ln, bar_index, close)

See also

Runs on Sidechair