FAQ

How to fix “syntax error at input ‘end of line without line continuation’.” in pine script

How to fix “syntax error at input ‘end of line without line continuation’.” in pine script

Simple code like this won’t work for you:

x = open > close ?  1 : 
    open < close ? -1 : 
    0

If you’ll add it to the chart you’ll see the following error: Syntax error at input ‘end of line without line continuation’.

So what is the reason and how to fix it? It is happening because of the line wrapping rules you have in PineScript. The piece of code you see on the screen is a single expression in few lines. When you want to wrap an expression in PineScript across few lines you have to use an indent in spaces which is not a multiple of 4. So you can use anything but 0, 4, 8, 12, etc. spaces. The reason is that 4x spaces indent is reserved for if, for, and custom function in PineScript.

Just adding 3 spaces as an indent will solve that problem for you:

x = open > close ?  1 : 
   open < close ? -1 : 
   0

Follow me on TradingView and YouTube.

This image has an empty alt attribute; its file name is wide.png
Pine Script Programming Courses
Pine Script Programming Courses
Learn to build your own TradingView Indicators and Strategies
Sidebar Signup Form
If you want to be the first in this business, subscribe to the latest news