Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS1004

error Only one indicator(...) or library(...) declaration is allowed.

#What it means

A script can declare itself only once. It is either one indicator or one library.

#Typical cause

  • Two scripts were pasted into one file.
  • A second indicator(...) was added to change the title or the overlay setting.

#How to fix it

Keep a single indicator(...) or library(...) call and put every setting you need into it. To show two separate things, save them as two scripts.

#Example

ChartScriptError: CS1004
//@chartscript 1
indicator("Moving average", { overlay: true })
indicator("Moving average 2", { overlay: true })
plot(ta.sma(close, 20))

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Moving average", { overlay: true })
plot(ta.sma(close, 20))
  • CS1003 — The script must start with indicator(...) or library(...) after the header.

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