Sidechair

box.set_lefttop()

Browse the reference

Moves the top-left corner of a box in one call, changing the left edge and the top edge together.

Try it in the editor

Both values are written before the next bar is drawn, so the corner never shows a half-moved state. The right and bottom edges are untouched.

Use it when a corner is anchored to an event such as a pivot, and box.set_rightbottom() for the opposite corner.

Syntax

Pine Script
box.set_lefttop(id: series box, left: series int, top: series int/float) -> void
box.set_lefttop(left: series int, top: series int/float) -> void

Arguments

NameTypeDefaultDescription
idseries boxrequiredThe box whose top-left corner moves.
leftseries intrequiredNew left edge: a bar index, or a timestamp in milliseconds for a box that uses xloc.bar_time. na hides the box.
topseries int/floatrequiredNew price of the top edge, set together with the left edge. na hides the box until a real price is set.

Returns

Nothing.

Remarks

  • On Sidechair: an na in either value hides the box until both are real numbers again.

Example

Pine ScriptMove the corner to each new pivot highOpen in editor
//@version=6
indicator("box.set_lefttop: follow the pivot", overlay = true)
ph = ta.pivothigh(high, 5, 5)
var box z = box.new(bar_index, high, bar_index + 1, low, bgcolor = color.new(color.green, 88))
if not na(ph)
    box.set_lefttop(z, bar_index - 5, ph)
box.set_right(z, bar_index)
box.set_bottom(z, ta.lowest(low, 30))

See also

Runs on Sidechair