Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS2703

error word can only be used inside a loop.

#What it means

break (leave the loop) and continue (skip to the next pass) only make sense inside a for or while loop.

#Typical cause

  • break or continue inside an if that is not in a loop.

#How to fix it

Remove it, or restructure the code with if / else. See Loops.

#Example

ChartScriptError: CS2703
//@chartscript 1
indicator("Skip")
const value = close
if (close < open) {
    break
}
plot(value)

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Skip")
const value = close < open ? na : close
plot(value)
  • CS2702 — A loop over the items of a list needs an array.

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