Sidechair

map.values()

Browse the reference

Returns the values of a map as a new array, in the order their keys were added.

Try it in the editor

The array is a copy that matches map.keys() position for position, so the value at index i belongs to the key at index i.

Feed it to array statistics such as array.avg() or array.max() to summarise everything the map holds.

Syntax

Pine Script
map.values(id: any map type) -> array<>
map.values() -> array<>

Arguments

NameTypeDefaultDescription
idany map typerequiredThe map whose values are listed. The values come back as a new array.

Returns

array<>: A new array holding the values.

Example

Pine ScriptAverage across the mapOpen in editor
//@version=6
indicator("map.values: average", overlay = false)
var m = map.new<int, float>()
map.put(m, bar_index % 5, close)
plot(array.avg(map.values(m)), "Mean of stored closes")

See also

Runs on Sidechair