Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS2404

error name cannot be changed (it is what).

#What it means

This name cannot be given a new value. The message says why: it is built in (like close or bar_index), declared with const, a function, a loop variable or a parameter.

#Typical cause

  • Assigning to a built-in series, such as close = ....
  • Changing a variable declared with const.
  • Changing a function parameter inside the function, or the variable of a for loop inside its body.

#How to fix it

For a const variable that has to change, declare it with let (the editor offers this quick fix). Otherwise declare your own variable with let and change that instead.

#Example

ChartScriptError: CS2404
//@chartscript 1
indicator("Smoothed close", { overlay: true })
close = (close + close[1]) / 2
plot(close)

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Smoothed close", { overlay: true })
const smooth = (close + close[1]) / 2
plot(smooth)
  • CS2403 — A function cannot change the global name unless it is declared with kw.
  • CS1036 — Only a variable or a field can be assigned to.

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