Skip to content
Algo Trade Analytics Docs

map.put() - Pine Script Function

Puts a new key-value pair into the id map.

map.put(id, key, value) → <value_type>
NameTypeDescription
idany map typeA map object.

The previous value associated with key if the key was already present in the map, or na if the key is new.

  • Maps maintain insertion order. Note that the order does not change when inserting a pair with a key that’s already in the map. The new pair replaces the existing pair with the key in such cases.
//@version=6
indicator("map.put example")
a = map.new<string, float>()map.put(a, "first", 10)map.put(a, "second", 15)prevFirst = map.put(a, "first", 20)currFirst = a.get("first")
plot(prevFirst)
plot(currFirst)