Sidechair

map.keys()

Browse the reference

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

Try it in the editor

The result is a copy. Changing the array does not change the map, and later changes to the map do not appear in an array you already took.

Loop over it to visit every pair: for k in map.keys(m), then read the value with map.get().

Syntax

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

Arguments

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

Returns

array<>: A new array holding the keys.

Example

Pine ScriptHighest keyOpen in editor
//@version=6
indicator("map.keys: highest key", overlay = false)
var m = map.new<int, float>()
map.put(m, bar_index % 7, close)
plot(array.max(map.keys(m)), "Largest key")

See also

Runs on Sidechair