Edgoro
Compile error · Syntax and indentation

Pine Script: end of line without line continuation (fix)

Fix the Pine Script error "Syntax error at input end of line without line continuation": how to wrap long lines and indent continuation lines in v6.

Pine Editor console · line 5
Syntax error at input "end of line without line continuation"

Cause

A statement is split across lines in a way Pine can't read: the continuation line is indented by a multiple of 4 spaces, which Pine reads as a block, so the first line ends on a dangling operator.

Broken code

TradingView reports the error on line 5.

Pine Script v6
//@version=6
indicator("Trend filter")
sma50  = ta.sma(close, 50)
sma200 = ta.sma(close, 200)
upTrend = close > sma50 and
    close > sma200
plot(upTrend ? 1 : 0)

Fixed code

The same script, corrected for Pine Script v6. Paste it into the Pine Editor and save.

Pine Script v6
//@version=6
indicator("Trend filter")
sma50  = ta.sma(close, 50)
sma200 = ta.sma(close, 200)
upTrend = close > sma50 and
  close > sma200
plot(upTrend ? 1 : 0)

Why it works

Pine Script lets you wrap a long statement over several lines, but each continuation line must be indented by a number of spaces that is not a multiple of 4. Four spaces (or a tab) mean "block", so in the broken version line 5 ended with and and nothing after it. With 2 spaces, Pine joins the two lines into one expression. Any indentation that isn't a multiple of 4 works: 1, 2, 3, 5, 6...

Other causes

  • An operator at the end of a line with nothing valid after it, for example x = close + followed by an unrelated statement.
  • A ternary split after : where the next line starts at column 0 instead of being indented as a continuation.
  • Function calls wrapped after a comma with 4-space indentation. Wrap them with 2 spaces as well:
plot(ta.sma(close, 20), "SMA 20",
  color.orange, 2)

Questions

How do I split a long line in Pine Script?

Break the line after an operator or a comma and indent the next line by a number of spaces that isn't a multiple of 4, for example 2 or 6. Function calls can be wrapped after any comma the same way.

Why does 4-space indentation break my wrapped line?

Because 4 spaces or a tab is how Pine marks a local block, such as the body of an if, a loop or a function. A continuation line indented by 4 looks like a block with no statement to own it.

The scripts on this page are minimal examples written to show the error and its fix, not trading systems. Trading involves substantial risk of loss and is not suitable for every investor. Edgoro is a software tool, not a broker or financial adviser: nothing it produces is investment advice, and past or backtested performance does not guarantee future results.

Still getting an error?

Paste your script and the message into the free Pine Script error fixer: it explains what went wrong and returns a corrected v6 version. Or describe the indicator in plain English and let Edgoro write the code.