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
//@chartscript 1
indicator("Counter")
let count = 0
count + 1 = 2
plot(count)Fixed
//@chartscript 1
indicator("Counter")
let count = 0
count = count + 2
plot(count)