Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS2710

error name can only be used at the top level of the script.

#What it means

settings.*, style.* and i18n.add describe the script's settings panel. They are read once, when the script is compiled, so they must sit at the top level, not inside a condition, loop or function.

#Typical cause

  • A settings statement placed inside an if, a loop or a function.

#How to fix it

Move the statement to the top level. To show or hide something depending on other inputs, use its visible_if argument. See Inputs.

#Example

ChartScriptError: CS2710
//@chartscript 1
indicator("Note")
if (close > open) {
    settings.note("Up bar")
}
plot(close)

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Note")
settings.note("Plots the close of every bar.")
plot(close)
  • CS2711 — The argument param of name must be a constant.
  • CS3007 — name can only be used at the top level of the script, not inside a condition, loop or function.

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