CS5105
error A map key cannot be na.
#What it means
A map key cannot be na. Every key must be a real value.
#Typical cause
- A key variable that is
naon some bars, for example a string that was never set.
#How to fix it
Check the key first: only put or get when !na(key). See Collections.
#Example
//@chartscript 1
indicator("Counts")
const counts = map.new<string, int>()
const key: string = na
counts.put(key, 1)
plot(counts.size())Fixed
//@chartscript 1
indicator("Counts")
const counts = map.new<string, int>()
const key: string = close > open ? "up" : "down"
if (!na(key)) {
counts.put(key, 1)
}
plot(counts.size())#Related
- CS5102 — name is na.