Sidechair

box.get_left()

Browse the reference

Returns the left edge of a box: a bar index, or a timestamp in milliseconds for a box placed with xloc.bar_time.

Try it in the editor

The value is in the unit the box was built with: a bar index for the default xloc, a timestamp otherwise. It is never converted for you.

bar_index - box.get_left(z) counts how many bars old a zone is, and box.get_right(z) - box.get_left(z) gives its width in the same unit.

Syntax

Pine Script
box.get_left(id: series box) -> series int
box.get_left() -> series int

Arguments

NameTypeDefaultDescription
idseries boxrequiredThe box to read the left edge from. na gives na back.

Returns

series int: Bar index of the left edge, or a millisecond timestamp for a box that uses xloc.bar_time.

Remarks

Example

Pine ScriptZone ageOpen in editor
//@version=6
indicator("box.get_left: zone age", overlay = false)
var box z = na
if bar_index % 40 == 0
    z := box.new(bar_index, high, bar_index + 10, low)
plot(na(z) ? na : bar_index - box.get_left(z), "Bars since zone began")

See also

Runs on Sidechair