Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS2001

error name is not defined.

#What it means

The script uses a name that was never declared and is not a built-in.

#Typical cause

  • A typo, such as closee for close.
  • A variable used before the line that declares it.
  • A variable declared inside a block (an if, a loop or a function) and used outside it.

#How to fix it

Check the spelling (the editor often suggests the closest name) and declare variables before you use them, in a block that contains every use. See Variables.

#Example

ChartScriptError: CS2001
//@chartscript 1
indicator("SMA", { overlay: true })
plot(ta.sma(closee, 14))

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("SMA", { overlay: true })
plot(ta.sma(close, 14))
  • CS2004 — name has no member member.
  • CS2401 — name is not declared; declare it with decl before assigning to it.

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