Counts the key and value pairs a map holds at this moment.
A new map has size 0. Each new key adds one; replacing the value of an existing key does not change the count.
It is the number to compare against a limit when a map should not grow without bound.
Syntax
map.size(id: any map type) -> series int
map.size() -> series intArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any map type | required | The map to count. Returns the number of key and value pairs it holds right now. |
Returns
series int: The number of pairs, as an integer.
Example
//@version=6
indicator("map.size: distinct levels", overlay = false)
var levels = map.new<float, int>()
map.put(levels, math.round(close), bar_index)
plot(map.size(levels), "Distinct whole-number closes")See also
Runs on Sidechair