CS1012
error This line's indentation does not match any open block.
#What it means
In the earlier syntax, when a block ended the next line had to line up with one of the blocks still open, and this line did not. Only scripts in the earlier syntax (saved before ChartScript moved to its current, brace-based syntax) can show it; the editor converts such a script to the current syntax when you open it, after which this cannot happen. In the current syntax a block ends at its }.
#Typical cause
- A line indented by 2 spaces after a block indented by 4.
- Mixed indentation widths after copying code.
#How to fix it
Open the script in the editor to convert it to the current syntax, or indent the line to the width of the block it belongs to.
#Example
In the earlier syntax
//@chartscript 1
indicator("Bar direction")
dir = 0
if close > open
dir := 1
dir := dir * 2
plot(dir)Fixed (the current syntax)
//@chartscript 1
indicator("Bar direction")
let dir = 0
if (close > open) {
dir = 1
}
dir = dir * 2
plot(dir)