CS2201
error Give name a type, for example: example
#What it means
A variable is declared with na as its starting value, which has no type, so the compiler cannot tell what kind of value it will hold.
#Typical cause
state x = na,let x = naorconst x = nawithout a type.
#How to fix it
Write the type after the name, for example state lastHigh: float = na (or let lastHigh: float). See Types.
#Example
//@chartscript 1
indicator("Last higher high", { overlay: true })
state lastHigh = na
if (high > high[1]) {
lastHigh = high
}
plot(lastHigh)Fixed
//@chartscript 1
indicator("Last higher high", { overlay: true })
state lastHigh: float = na
if (high > high[1]) {
lastHigh = high
}
plot(lastHigh)