Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS2711

error The argument param of name must be a constant.

#What it means

Settings statements are read when the script is compiled, before any bar exists, so this argument must be a constant such as a literal string or number.

#Typical cause

  • A title, id or name built from a variable or a bar value.

#How to fix it

Write the value directly as a literal.

#Example

ChartScriptError: CS2711
//@chartscript 1
indicator("Sections")
const name = "Trend " + str.tostring(bar_index)
settings.section("main", name)
const len = input.int(14, "Length")
plot(ta.sma(close, len))

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Sections")
settings.section("main", "Trend")
const len = input.int(14, "Length")
plot(ta.sma(close, len))
  • CS2710 — name can only be used at the top level of the script.
  • CS2103 — The argument param of name must be a constant.

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