Skip to content
Algo Trade Analytics Docs

map.keys() - Pine Script Function

Returns an array of all the keys in the id map. The resulting array is a copy and any changes to it are not reflected in the original map.

map.keys(id) → array<type>
NameTypeDescription
idany map typeA map object.
  • Maps maintain insertion order. The elements within the array returned by this function will also be in the insertion order.
//@version=6
indicator("map.keys example")
a = map.new<string, float>()a.put("open", open)a.put("high", high)a.put("low", low)a.put("close", close)keys = map.keys(a)ohlc = 0.0
for key in keys ohlc +=
a.get(key)
plot(ohlc/4)