Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS1036

error Only a variable or a field can be assigned to.

#What it means

The left side of =, += and the other assignment operators (and of ++ / --) must be a variable or a field of an object. This one is a calculation, a call or a history reference.

#Typical cause

  • An expression on the left, as in count + 1 = 2.
  • Assigning to a past value, as in x[1] = 0. History cannot be changed.

#How to fix it

Assign to the variable itself, and put the calculation on the right side.

#Example

ChartScriptError: CS1036
//@chartscript 1
indicator("Counter")
let count = 0
count + 1 = 2
plot(count)

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Counter")
let count = 0
count = count + 2
plot(count)
  • CS2401 — name is not declared; declare it with decl before assigning to it.
  • CS2404 — name cannot be changed (it is what).

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