Removes a box from the chart; the variable that held it keeps pointing at the removed rectangle.
The rectangle stops drawing and no longer counts toward the box cap. Deleting na, or deleting the same box twice, does nothing, so a guard around the call is unnecessary.
Pair it with a var box to keep a single zone alive: delete the old one, then assign the new one to the same variable. The variable is not reset to na by the delete itself.
Syntax
box.delete(id: series box) -> void
box.delete() -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series box | required | The box to remove from the chart. na, or a box that is already gone, is ignored. |
Returns
Nothing.
Remarks
- A box kept in an array has to leave the array as well, with
array.remove()orarray.shift(); deleting the drawing leaves a stale reference behind. - On Sidechair: deleting something that is not a box, such as a line, is ignored, and the removed box still answers
box.get_left()and the other readers with its old edges.
Example
//@version=6
indicator("box.delete: replace", overlay = true)
var box z = na
box.delete(z)
z := box.new(bar_index - 15, ta.highest(high, 15), bar_index, ta.lowest(low, 15), bgcolor = color.new(color.teal, 88))See also
Runs on Sidechair