Skip to content
ChartDeck ChartScript docs Account Open the terminal

CS1034

error Expected a block { … }.

#What it means

An if, else, loop, switch, type, enum or function needs a body: a block { … }, or (for if, else and loops) a single statement. Here the script ends, or a block closes, before the body.

#Typical cause

  • An if or loop head with nothing after it, often left behind while editing.
  • A missing { after the head.

#How to fix it

Add the body in braces, if (cond) { … }, or remove the unfinished line. See Conditionals.

#Example

ChartScriptError: CS1034
//@chartscript 1
indicator("Up bars")
let dir = 0
if (close > open) {
    if (volume > volume[1])
}
plot(dir)

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Up bars")
let dir = 0
if (close > open) {
    dir = 1
}
plot(dir)
  • CS1031 — open is not closed.
  • CS1030 — Expected expected but found found.

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