array.push adds the newest box at the end; array.shift removes and returns the oldest, which box.delete removes from the chart.
The same pattern works for line and label arrays.
The limits
These are arguments of
indicator and strategy. A value above the highest is clamped, not refused; zero or a negative value gives
the default. They must be constants: an input is refused.
When a kind goes a few over its limit, the oldest drawings of that kind are deleted until the count is back at the limit.
A line, label, box or linefill held directly in a static variable (as in How to keep one label that moves) is
skipped and never trimmed, but a drawing held only inside an array is not protected. Keep your array’s cap at or below the limit, as
above, so that your own deletion always comes first and the array never holds a drawing the script has already lost.