TradingCharts

Expected End of Line

Something followed a complete statement before the newline — usually a stray token the parser cannot interpret.

Common causes

1. An unexpected number in an import path

Older scripts wrote numeric owner ids as /1000000072/ and the parser treated the segment as a number literal. Modern ChartScript accepts numeric owners through the normal import grammar, so this message now almost always means a different mistake — a stray token on a line that should end:

plot(close) 42        // ⚠ Expected 'end of line', got '42'

2. Missing comma inside a call

plot(close "SMA 20"   color=color.aqua)
                ^ ⚠ Expected 'end of line', got '"SMA 20"'

Add the commas:

plot(close, "SMA 20", color=color.aqua)

3. Line-continuation operator broken by whitespace

The compiler's line-continuation rule requires the operator and a whitespace to be on the next line:

total = volume +
          volume[1]        // ⚠ the second line starts with +, which continues; OK
total = volume
      +volume[1]           // ⚠ no space after `+` — treated as a new statement

Add a space after the operator or move it to the end of the previous line.

4. Assigning the result of a block to a mis-indented variable

value =
if cond                    // ⚠ `if` must be indented
    1
else
    0

Indent the block:

value =
    if cond
        1
    else
        0