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
ifor 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
//@chartscript 1
indicator("Up bars")
let dir = 0
if (close > open) {
if (volume > volume[1])
}
plot(dir)Fixed
//@chartscript 1
indicator("Up bars")
let dir = 0
if (close > open) {
dir = 1
}
plot(dir)