Sidechair

box.get_right()

Browse the reference

Returns the right 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

A box stretched with extend.right still reports the right edge that was stored, not the chart's edge.

Use it to tell whether price has moved past the end of a zone, or to stretch the box one bar further each bar with box.set_right(z, box.get_right(z) + 1).

Syntax

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

Arguments

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

Returns

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

Remarks

  • On Sidechair: a right edge ahead of the last bar is returned as stored, and an na or non-box argument returns na.

Example

Pine ScriptGrow a box by one barOpen in editor
//@version=6
indicator("box.get_right: grow", overlay = true)
var box z = box.new(bar_index, high, bar_index + 1, low, bgcolor = color.new(color.green, 85))
box.set_right(z, box.get_right(z) + 1)

See also

Runs on Sidechair