Returns the left edge of a box: a bar index, or a timestamp in milliseconds for a box placed with xloc.bar_time.
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
box.get_left(id: series box) -> series int
box.get_left() -> series intArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series box | required | The 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
box.set_left()andbox.set_lefttop()change what this returns.box.set_extend()does not, because an extended box keeps its stored edge.- On Sidechair: a box that is na, or a value that is not a box, makes it return na.
Example
//@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