Removes every pair from a map, leaving it empty.
The map itself stays valid, so it can be filled again. Other variables that refer to it see the empty map.
Clear a var map at the start of each session to reuse it.
Syntax
map.clear(id: any map type) -> void
map.clear() -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any map type | required | The map to empty. The key and value types stay as declared; only the pairs are removed. |
Returns
Nothing.
Example
//@version=6
indicator("map.clear: daily reset", overlay = false)
var m = map.new<int, float>()
if timeframe.change("D")
map.clear(m)
map.put(m, bar_index, close)
plot(map.size(m), "Pairs today")See also
Runs on Sidechair