Returns the value stored under a key, or na when the key is not in the map.
The lookup does not change the map. A missing key gives na, so pair it with nz() or with map.contains() when na would be confused with a stored value.
For a bool map a missing key reads as false, and for a string map as na.
Syntax
map.get(id: any map type, key: series <type of the map's elements>) -> <value_type>
map.get(key: series <type of the map's elements>) -> <value_type>Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any map type | required | The map to read a value from. The map itself is not changed. |
| key | series <type of the map's elements> | required | The key whose value is returned. It has to match the key type of the map. |
Returns
<value_type>: The stored value, or na.
Example
//@version=6
indicator("map.get: thresholds", overlay = false)
var limits = map.new<string, float>()
if barstate.isfirst
map.put(limits, "high", 70.0)
map.put(limits, "low", 30.0)
r = ta.rsi(close, 14)
plot(r, "RSI")
hline(map.get(limits, "high"))
hline(map.get(limits, "low"))See also
Runs on Sidechair