box - Pine Script Variable
Overview
Section titled “Overview”Collections of box drawings created by your script.
Fields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
box.all | array<box> | Returns an array filled with all the current boxes drawn by the script. |
Remarks
Section titled “Remarks”box.all: The array is read-only. Index zero of the array is the ID of the oldest object on the chart.
Example
Section titled “Example”//@version=6indicator("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))