FAQ – “Syntax error at input ‘end of line without line continuation’.” – how to fix?

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.