Moves only the end of a line sideways, along the bar axis.
Calling it with bar_index each bar stretches the line along with the chart while the start stays fixed. Stop calling it and the line freezes at its last bar.
extend.right continues past the second point whichever side that point is on, so an x2 smaller than x1 sends a rightward extension toward the left of the chart.
Syntax
line.set_x2(id: series line, x: series int) -> void
line.set_x2(x: series int) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series line | required | The line whose second point moves along the bar axis; the first point stays put. |
| x | series int | required | New bar index, or millisecond timestamp on a bar_time line, for the second point. It may be smaller than x1. |
Returns
Nothing.
Example
//@version=6
indicator("line.set_x2: grow until broken", overlay = true)
ph = ta.pivothigh(high, 5, 5)
var line lvl = na
if not na(ph)
lvl := line.new(bar_index - 5, ph, bar_index, ph, color = color.orange)
if not na(lvl) and line.get_x2(lvl) == bar_index - 1 and close < line.get_y2(lvl)
line.set_x2(lvl, bar_index)See also
Runs on Sidechair