Sidechair

box.set_right()

Browse the reference

Moves the right edge of a box to a new bar or timestamp, so the zone ends earlier or later.

Try it in the editor

Calling box.set_right(z, bar_index) on every bar keeps a zone growing with the chart. The left edge stays where it was created.

A box that should reach the chart edge without being updated needs extend.right instead, which leaves the stored right edge unchanged. A right edge ahead of the last bar, such as bar_index + 20, projects the zone forward.

Syntax

Pine Script
box.set_right(id: series box, right: series int) -> void
box.set_right(right: series int) -> void

Arguments

NameTypeDefaultDescription
idseries boxrequiredThe box whose right edge moves.
rightseries intrequiredNew right edge: a bar index, or a timestamp in milliseconds for a box that uses xloc.bar_time. It may lie ahead of the last bar; na hides the box.

Returns

Nothing.

Remarks

  • On Sidechair: with xloc.bar_time a timestamp after the last bar is placed ahead of it, one bar per timeframe step.

Example

Pine ScriptZone that grows until brokenOpen in editor
//@version=6
indicator("box.set_right: grow until broken", overlay = true)
var box z = box.new(bar_index, high, bar_index + 1, low, bgcolor = color.new(color.orange, 88))
if close >= box.get_bottom(z)
    box.set_right(z, bar_index)

See also

Runs on Sidechair