Creates an empty map for the key type and value type given in angle brackets.
Write both types after the name: map.new<string, float>() maps text keys to decimals, and map.new<int, label>() maps integers to labels. The map starts with no pairs.
Create it with var to keep its contents from one bar to the next. A map made on every bar without var starts empty each time.
Syntax
map.new() -> map<keyType, valueType>Returns
map<keyType, valueType>: A new, empty map.
Remarks
- On Sidechair: when the angle brackets are left out, the map defaults to string keys and float values.
Example
//@version=6
indicator("map.new: volume by weekday", overlay = false)
var byDay = map.new<int, float>()
d = dayofweek
map.put(byDay, d, nz(map.get(byDay, d)) + volume)
plot(nz(map.get(byDay, d)), "Total volume on this weekday")See also
Runs on Sidechair