Removes every item from an array, leaving it empty.
The size drops to 0 but the array itself stays valid and can be filled again. Variables that point at the same array see it empty too.
Clearing is the cheap way to reuse one var array for each new session or signal instead of creating a new array.
Syntax
array.clear(id: any array type) -> void
array.clear() -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any array type | required | The array to empty. Its type stays; only the items are removed. |
Returns
Nothing.
Remarks
- If the array holds lines, labels or boxes, clearing it does not delete the drawings from the chart. Call
line.delete(),label.delete()orbox.delete()on each item first.
Example
//@version=6
indicator("array.clear: daily reset", overlay = false)
var day = array.new_float()
if timeframe.change("D")
array.clear(day)
array.push(day, close)
plot(array.size(day), "Bars today")See also
Runs on Sidechair