Hi i can seem to fix the error
strategy("Recon EMA CROS RSI 40", shorttittle = "EMA X RSI", overlay=true, inital_capital = 10, default_qty_value = 100, default_QTY_TYPE = strategy.percent_of_equity, commision_value = 0.08)
// Input
EMA1 = input(title="fast EMA", type=input.integer, defval=9)
EMA2 = input(title="Slow EMA", type=input.integer, defval=24)
//Calculation
fastEMA = ema(close, EMA1)
slowEMA = ema(close, EMA2)
//Strategy
goLongCondition1 = crossover(fastEMA, slowEMA)
goLongCondition2 = (rsi(close,9) > 40)
exitCondition1 = crossover(slowEMA, fastEMA)
exitCondition2 = (rsi(close,9) < 40)
inTrade = strategy.position_size > 0
notOnTrade = strategy.position_size <= 0
timePeriod = time >= timestamp(system.timezone, 2023, 01, 01, 0, 0)
if (timePeriod and goLongCondition1 and goLongCondition2 and notOnTrade)
strategy.entry("long", strategy.long, qty=default_qty_value, qtytype = default_QTY_TYPE, when=notOnTrade)
stoploss = low * .9
strategy.exit("exit", "long", stop=stoploss, when=notOnTrade)
if (exitCondition1 and exitCondition2 and inTrade)
strategy.close("long")
//PLOT
plot(fastEMA, color=color.yellow)
plot(slowEMA, color=color.blue)
bgcolor(notOnTrade ? color.red : color.green)
In pinescript, you must respect the 4 spaces after the line with the if command.
In your code, there is 5 spaces, this is the root of the error.
You should replace your 2 if block with :
But your code as several other errors. Please correct them as they appear and do not hesitate to ask for another question.