Olivia Moore
Olivia Moore

Reputation: 1

Formatting error with pinescript strategy 'Mistmatched input 'strategy' expecting 'end of line without line continuation'

Hello I am trying to write a strategy where it buys when the MFI is oversold & the EMA is above 200. This code doesn't seem to wanna run. I keep getting an error saying "Line 2: mismatched input 'strategy' expecting 'end of line without line continuation'. Can someone please help? thank you :)

//@version=5
strategy("MFI Oversold Above 200 EMA")
// MFI Oversold
mfi = money_flow_index(14)
oversold = mfi < 20
// 200 EMA
ema200 = ema(close, 200)
// Buy when MFI is oversold and above 200 EMA
if oversold and close > ema200
strategy.entry("Long", strategy.long)
// Sell when MFI is not oversold or below 200 EMA
if not oversold or close < ema200
strategy.close("Long")
// Plot MFI
plot(mfi, title="MFI", color=color.yellow)
// Plot 200 EMA
plot(ema200, title="200 EMA", color=color.blue)
// Plot buy signals
plot(oversold and close > ema200, title="Buy", style=plot.style_cross,
color=color.green, linewidth=3)
// Plot sell signals
plot(not oversold or close < ema200, title="Sell", style=plot.style_cross,
color=color.red, linewidth=3)

Upvotes: 0

Views: 59

Answers (1)

G.Lebret
G.Lebret

Reputation: 3108

In your code, you should :

Upvotes: 0

Related Questions