Sidechair

box.set_xloc()

Browse the reference

Replaces both horizontal edges of a box and switches them between bar indexes and millisecond timestamps in one call.

Try it in the editor

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

Pine Script
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) -> void

Arguments

NameTypeDefaultDescription
idseries boxrequiredThe box whose horizontal edges and edge unit change.
leftseries intrequiredNew left edge in the unit named by xloc: a bar index for xloc.bar_index, a timestamp in milliseconds for xloc.bar_time.
rightseries intrequiredNew right edge in the unit named by xloc: a bar index for xloc.bar_index, a timestamp in milliseconds for xloc.bar_time.
xlocseries stringrequiredxloc.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_time puts 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

Pine ScriptPin a box to two timestampsOpen in editor
//@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