SuperCharting
Sign in Get started Account Open charts

Learn / Pine Script errors

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

Fix the Pine Script syntax error "end of line without line continuation": indent wrapped lines by a number of spaces that is not a multiple of 4.

"Syntax error at input 'end of line without line continuation'" means Pine found a line break in the middle of a statement and could not tell that the next line carries on from it. It almost always comes from how a long line was wrapped. The fix is to indent each continuation line by a number of spaces that is not a multiple of 4, such as 1, 2 or 5.

What causes it

Pine uses indentation for two different jobs, and this error is what happens when the two get mixed up.

So 4 and 8 are reserved for blocks. A continuation line indented by exactly 4 spaces looks like the start of a block, and Pine reports that the previous line ended without a proper continuation.

A wrapped line indented by 4 spaces

This is the usual case. The writer breaks a ? : expression after the ? and indents the rest with 4 spaces, the same indent used for blocks. It FAILS on TradingView:

//@version=6
indicator("Wrap")
x = close > open ?
    close : open
plot(x)

Line 4 starts with 4 spaces, so Pine reads it as a block indent.

A comment inside a wrapped expression

TradingView's documentation shows this error coming from a comment at the end of a line inside a wrapped statement, even when the indentation is right. Code written like this is at risk on TradingView:

x = close > open ? // up bars use the close
     close : open

An unmatched bracket on an earlier line

Sometimes the message is misleading. If a bracket opened on a line above was never closed, or was closed twice, Pine may report the problem as a missing line continuation further down. When the indentation on the reported line looks fine, count the brackets on the lines above it.

How to fix it

Indent the continuation line by a number of spaces that is not a multiple of 4. This is the tested fix for the first example, with 5 spaces in front of line 4:

//@version=6
indicator("Wrapped line")
x = close > open ?
     close : open
plot(x)

The difference from the broken version is one space, which is easy to miss when you read the code. Turn on visible whitespace in your editor if you wrap lines often.

Two spaces work as well. Here a long plot() call is wrapped after each argument:

//@version=6
indicator("Wrapped arguments", overlay = true)
plot(ta.sma(close, 20),
  "SMA 20",
  color.blue,
  2)

For the comment case, move the comment above the statement:

//@version=6
indicator("Comment moved")
// pick the close on up bars, the open on down bars
x = close > open ?
     close : open
plot(x)

For a bracket problem, fix the bracket first. The continuation message usually goes away with it.

A few habits prevent the error:

  1. Pick one continuation indent, such as 2 or 5 spaces, and use it everywhere in the script.
  2. Do not let your editor turn a wrapped line's indent into a tab.
  3. Keep comments out of wrapped statements.
  4. If a line is short enough, do not wrap it at all.

What SuperCharting's Script Editor shows

SuperCharting's engine is more lenient here and runs this code. The first broken example, with the 4-space continuation, compiles and runs in the Script Editor without an error. If the script must also work on TradingView, fix it the way shown above.

That means the editor will not warn you about a 4-space continuation. Check wrapped lines by eye before you share a script with someone who runs it on TradingView.

To check your script:

  1. Open the Script Editor with Ctrl + E.
  2. Paste the script into the code area.
  3. Read the console, then press Add to chart.

The Script Editor page covers the editor's layout and buttons, and the Pine Script code checker page lists what the built-in Auto-fix repairs, including tab indents. Pine Script v6 basics explains blocks and indentation from the start.

Indentation causes more than one Pine error. A statement indented when it should start at the left margin gives mismatched input, which is the error to look at if your problem is a stray space at the start of a line instead of a wrapped one. Once a wrapped expression parses, a wrong value type inside it can still fail, for example a series int where a simple int is expected.

Frequently asked questions

How many spaces should a continuation line have?

Any number that is not a multiple of 4. One, 2, 3, 5 or 6 all work. Four and 8 are read as block indents.

Can I use a tab to indent a wrapped line?

Type spaces instead, so you know exactly how many there are. The count is what matters, and a tab hides it.

Why does a comment break my wrapped line?

TradingView's documentation shows a comment inside a wrapped statement causing this error. Put the comment on the line above the statement and the problem cannot happen.

The indentation looks right but the error stays. What else can it be?

An unmatched bracket on an earlier line can produce the same message. Count the opening and closing brackets above the line the error names.

TradingView and Pine Script are trademarks of TradingView, Inc. SuperCharting is independent and not affiliated with it.

Try it on a live chart

SuperCharting is an AI-enabled charting and coding platform in your browser: charts, Pine-compatible scripts with AI Auto-fix, the Strategy Tester, alerts and the screener.

Create a free account More guides