Skip to content
Algo Trade Analytics Docs

box - Pine Script Variable

Collections of box drawings created by your script.

FieldTypeDescription
box.allarray<box>Returns an array filled with all the current boxes drawn by the script.
  • box.all: The array is read-only. Index zero of the array is the ID of the oldest object on the chart.
//@version=6
indicator("Box cleanup", overlay=true, max_boxes_count=5)
if barstate.isfirst
box.new(bar_index, high, bar_index + 5, low,
bgcolor=color.new(color.blue, 85),
border_color=color.new(color.blue, 0))
if barstate.islast
boxes = box.all
if array.size(boxes) > 0
for i = 0 to array.size(boxes) - 1
box.delete(array.get(boxes, i))