Search code examples
pine-scriptbitcoinalgorithmic-tradingtradingmismatch

*Resolved* Pine Script mismatched input, expecting 'end of line without line continuation'


I'm trying to code a trading strategy in pine script. I just have a little problem in my code at line 100:

line 100: Mismatched input 'strategy.entry' expecting 'end of line without line continuation'

I tryed to search by my own but found nothing it's the reason why I'm asking here. By the way, I'm in version 4 of pine script.


buytrend = 0

if supertrend == 1 and supertrend2 == 1
    buytrend = 1
else if supertrend3 == 1 and supertrend == 1
    buytrend = 1
if supertrend2 == 1 and supertrend3 == 1
    buytrend = 1

if supertrend == -1 and supertrend2 == -1
    buytrend = 0
else if supertrend3 == -1 and supertrend == -1
    buytrend = 0
if supertrend2 == -1 and supertrend3 == -1
    buytrend = 0


//plot marketprice

marketprice = ema(close,1)
plot(marketprice,"Marketprice",color.yellow)

//signals

Buysignal = crossover(k, d) and k < 20 and marketprice > ema and buytrend == 1
Sellsignal = crossunder(k, d)
Sellsignal2 = if buytrend == 0

//strategy

strategy.entry("Trade",strategy.long,when = Buysignal)
strategy.close("Trade",when = Sellsignal)
strategy.exit("Trade",when = Sellsignal2) ```

Solution

  • vitruvius's answer is correct, but specifically if you're trying to set Sellsignal2 to equal True or False, then you don't need the if

    Just assign it the result of evaluating buytrend == 0 as in:

    Sellsignal2 = buytrend == 0