Sidechair

map.clear()

Browse the reference

Removes every pair from a map, leaving it empty.

Try it in the editor

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

Pine Script
map.clear(id: any map type) -> void
map.clear() -> void

Arguments

NameTypeDefaultDescription
idany map typerequiredThe map to empty. The key and value types stay as declared; only the pairs are removed.

Returns

Nothing.

Example

Pine ScriptDaily resetOpen in editor
//@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