Relocates the end of a line to a new bar and price in one call.
Calling line.set_xy2(ln, bar_index, close) each bar makes the right end track the live price while the left end stays anchored, like a rubber band.
A line created with equal x values is a vertical stub until this call gives the second point a different bar.
Syntax
line.set_xy2(id: series line, x: series int, y: series int/float) -> void
line.set_xy2(x: series int, y: series int/float) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series line | required | The line whose second point is moved; the first point stays anchored. |
| x | series int | required | Bar index, or millisecond timestamp on a bar_time line, of the new second point. |
| y | series int/ | required | Price of the new second point, in chart price units. |
Returns
Nothing.
Example
//@version=6
indicator("line.set_xy2: live rubber band", overlay = true)
var line ln = na
if timeframe.change("D")
ln := line.new(bar_index, open, bar_index, close, color = color.blue)
line.set_xy2(ln, bar_index, close)See also
Runs on Sidechair