Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS5102

error name is na.

#What it means

The script used an array, map, matrix or object that is na (it was never created), so there is nothing to read from or write to.

#Typical cause

  • A collection declared as na and never given a value, as in state xs: float[] = na.
  • A field of an object read before the object was created.

#How to fix it

Create the collection when you declare it, for example state xs = array.new<float>(), or check with na(xs) before using it. See Collections.

#Example

ChartScriptOpen in editor
//@chartscript 1
indicator("Stored closes")
state closes: float[] = na
closes.push(close)
plot(closes.size())

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Stored closes")
state closes: float[] = array.new<float>()
closes.push(close)
plot(closes.size())
  • CS5101 — Index index is out of range (size size).
  • CS5105 — A map key cannot be na.

The ChartScript documentation is in English for now; translations will follow.