Returns where a line starts on the x axis, as a bar index or a millisecond timestamp.
The number is in the scale the line was created in, so a line placed with xloc.bar_time returns a timestamp. Right after line.set_x1() or line.set_xy1() it returns the new value, and after line.set_xloc() the new scale.
Subtract it from bar_index to measure how long a line has been alive. Asking a na line gives na.
Syntax
line.get_x1(id: series line) -> series int
line.get_x1() -> series intArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series line | required | The line to read the first point's x coordinate from. |
Returns
series int: The x coordinate of the first point.
Example
//@version=6
indicator("line.get_x1: line age", overlay = false)
var line ln = na
if bar_index % 60 == 0
ln := line.new(bar_index, close, bar_index + 5, close)
plot(na(ln) ? na : bar_index - line.get_x1(ln), "Bars since start")See also
Runs on Sidechair