Replaces both horizontal edges of a box and switches them between bar indexes and millisecond timestamps in one call.
Bar indexes and timestamps are different scales, so the edges and the mode change together: box.set_xloc(z, t1, t2, xloc.bar_time). Changing only the mode would read the old numbers in the wrong unit.
A box placed by time keeps its place when the loaded history changes, because a timestamp does not depend on how many bars are in memory.
Syntax
box.set_xloc(id: series box, left: series int, right: series int, xloc: series string) -> void
box.set_xloc(left: series int, right: series int, xloc: series string) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series box | required | The box whose horizontal edges and edge unit change. |
| left | series int | required | New left edge in the unit named by xloc: a bar index for xloc.bar_index, a timestamp in milliseconds for xloc.bar_time. |
| right | series int | required | New right edge in the unit named by xloc: a bar index for xloc.bar_index, a timestamp in milliseconds for xloc.bar_time. |
| xloc | series string | required | xloc.bar_index reads left and right as bar indexes; xloc.bar_time reads them as timestamps in milliseconds. |
Returns
Nothing.
Remarks
- On Sidechair: this function is not supported yet, so a call reports a warning and changes nothing. Create the box with xloc in
box.new()instead. - On Sidechair: a box created with
xloc.bar_timeputs each timestamp on the first bar that opens at or after it, and a timestamp past the last bar lands that many timeframe steps ahead of it.
Example
//@version=6
indicator("box.set_xloc: by time", overlay = true)
var box z = box.new(bar_index, high, bar_index + 1, low)
box.set_xloc(z, time[10], time, xloc.bar_time)See also
Not on Sidechair yet