CS2002
error name is already declared in this block (line line).
#What it means
A name is declared twice in the same block. The message gives the line of the first declaration.
#Typical cause
const x = ...orlet x = ...written twice where the second should change the value: writex = ...withoutletto change a variable.- Two parameters, fields or enum items with the same name.
- A local name that is the same as a name brought in by
import { … }.
#How to fix it
Change the existing variable with x = ... (declare it with let so it can change), or pick a different name for the second one. See Variables.
#Example
//@chartscript 1
indicator("Length")
const len = 14
const len = 20
plot(ta.sma(close, len))Fixed
//@chartscript 1
indicator("Length")
let len = 14
len = 20
plot(ta.sma(close, len))