Rewrites both x values of a line and switches them between bar indexes and timestamps.
A bar index and a timestamp are different numbers, so x1, x2 and xloc go in together: line.set_xloc(ln, t1, t2, xloc.bar_time). The prices stay as they were.
A line placed by time keeps its moments when the chart changes timeframe; a line placed by index keeps its bar count.
Syntax
line.set_xloc(id: series line, x1: series int, x2: series int, xloc: series string) -> void
line.set_xloc(x1: series int, x2: series int, xloc: series string) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series line | required | The line to re-express in another x scale; its prices are not touched. |
| x1 | series int | required | New x of the first point, written in the scale that xloc selects. |
| x2 | series int | required | New x of the second point, written in the scale that xloc selects. |
| xloc | series string | required | xloc.bar_index treats x1 and x2 as bar indexes; xloc.bar_time treats them as millisecond timestamps. |
Returns
Nothing.
Remarks
- On Sidechair: a timestamp that falls between bars lands on the next bar, and one after the last bar is placed ahead of it by the elapsed time measured in bar lengths of the chart's timeframe.
Example
//@version=6
indicator("line.set_xloc: project ahead", overlay = true)
var line ln = line.new(bar_index, close, bar_index + 1, close, color = color.fuchsia)
line.set_xloc(ln, time, time + 5 * timeframe.in_seconds() * 1000, xloc.bar_time)
line.set_y1(ln, close)
line.set_y2(ln, close + ta.atr(5))See also
Runs on Sidechair