Returns where a line ends on the x axis, as a bar index or a millisecond timestamp.
It is the stored second point. A line that extends to the right still reports the bar it was given, never the right edge of the chart.
Together with line.get_x1() it gives the width of the segment in bars. A na id yields na here too.
Syntax
line.get_x2(id: series line) -> series int
line.get_x2() -> series intArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series line | required | The line to read the second point's x coordinate from. |
Returns
series int: The x coordinate of the second point.
Example
//@version=6
indicator("line.get_x2: segment length", overlay = false)
var line ln = line.new(0, 0, 1, 1)
if bar_index % 50 == 0
ln := line.new(bar_index - 10, low, bar_index, high)
plot(line.get_x2(ln) - line.get_x1(ln), "Width in bars")See also
Runs on Sidechair