Skip to content
Algo Trade Analytics Docs

map.new<type,type>() - Pine Script Function

Creates a new map object: a collection that consists of key-value pairs, where all keys are of the keyType, and all values are of the valueType.

map.new<keyType, valueType>() → map<keyType, valueType>

The ID of a map object which may be used in other map.*() functions.

  • Each key is unique and can only appear once. When adding a new value with a key that the map already contains, that value replaces the old value associated with the key.
//@version=6
indicator("map.new<string, int> example")
a = map.new<string, int>()a.put("example", 1)
label.new(bar_index, close, str.tostring(a.get("example")))