CS2405
error name is expected; it cannot be given a got value.
#What it means
A variable keeps the type it was declared with. Here it is given a value of another type that cannot be converted automatically. The only automatic conversion is from int to float.
#Typical cause
- A variable declared as
int(or started with a whole number such as0) and later given afloatsuch as a price. - A string given to a number variable, or the other way round.
#How to fix it
Declare the variable with the wider type (let x: float = 0 or let x = 0.0), or convert the value explicitly with int(...). See Types.
#Example
//@chartscript 1
indicator("Last close")
let last: int = 0
last = close
plot(last)Fixed
//@chartscript 1
indicator("Last close")
let last: float = 0
last = close
plot(last)