Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS2008

error Expected expected but got got.

#What it means

A value has the wrong type for where it is used. The message gives the type that was needed and the one that was found.

#Typical cause

  • A number written as a string, as in "14".
  • A string or colour used in arithmetic.
  • The two sides of ?: or of an if expression have types that do not mix.
  • A function, type or namespace used where a value is needed.

#How to fix it

Give a value of the expected type. Convert explicitly where needed: str.tostring(x) for text, int(x) for a whole number. See Types.

#Example

ChartScriptError: CS2008
//@chartscript 1
indicator("SMA", { overlay: true })
plot(ta.sma(close, "14"))

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("SMA", { overlay: true })
plot(ta.sma(close, 14))
  • CS2405 — name is expected; it cannot be given a got value.
  • CS2701 — A condition must be a bool, but this is got.

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