Skip to content
ChartDeck ChartScript docs Account Open the terminal

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 as 0) and later given a float such 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

ChartScriptError: CS2405
//@chartscript 1
indicator("Last close")
let last: int = 0
last = close
plot(last)

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Last close")
let last: float = 0
last = close
plot(last)
  • CS2008 — Expected expected but got got.
  • CS2201 — Give name a type, for example: example

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