Sidechair

box.set_top()

Browse the reference

Moves the top edge of a box to a new price, so the box grows taller or shorter from above.

Try it in the editor

The bottom edge and both sides stay put. Raising the top makes the box taller; lowering it cuts the box down from above.

Read box.get_top() first when the ceiling should only ever rise, as in math.max(box.get_top(z), high).

Syntax

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

Arguments

NameTypeDefaultDescription
idseries boxrequiredThe box whose top edge moves.
topseries int/floatrequiredNew price of the top edge, in the chart's price units. na hides the box until a real price is set.

Returns

Nothing.

Remarks

  • On Sidechair: a top set below the bottom keeps both numbers as given and draws the same rectangle, and box.get_top() returns the number you passed.

Example

Pine ScriptCeiling that only ratchets upOpen in editor
//@version=6
indicator("box.set_top: ceiling that ratchets", overlay = true)
var box z = box.new(bar_index, high, bar_index + 1, low, bgcolor = color.new(color.red, 88))
box.set_right(z, bar_index)
box.set_top(z, math.max(box.get_top(z), high))

See also

Runs on Sidechair