Moves only the start of a line sideways, along the bar axis.
The price at the start stays, so the line pivots around its other end as the start slides. Moving the start back over history lengthens it; setting it equal to x2 makes the line vertical.
The value goes in as given, so an x1 larger than x2 is allowed; the ends keep their first and second roles.
Syntax
line.set_x1(id: series line, x: series int) -> void
line.set_x1(x: series int) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series line | required | The line whose first point moves along the bar axis. na is accepted and ignored. |
| x | series int | required | New bar index, or millisecond timestamp on a bar_time line, for the first point. The price is unchanged. |
Returns
Nothing.
Remarks
- On Sidechair: a na x leaves the line undrawn until the start gets a number again, and
line.get_x1()returns na in the meantime.
Example
//@version=6
indicator("line.set_x1: session restart", overlay = true)
var line ln = line.new(bar_index, open, bar_index + 1, open, color = color.gray)
if timeframe.change("D")
line.set_x1(ln, bar_index)
line.set_y1(ln, open)
line.set_x2(ln, bar_index)
line.set_y2(ln, line.get_y1(ln))See also
Runs on Sidechair