Trying to add RSI as well, but either my conditions are wrong, or they never happen at the same time.
// © iamchaoticcoder
//@version=4
strategy(title="MA Crossover with RSI", overlay=true, initial_capital=2000, commission_type=strategy.commission.percent, commission_value=0.2)
//commission value like Kraken
//Define defaults for Inputs
fromMonth = input(defval =1, title ="from month",minval=1)
fromDay = input(defval =1, title ="to month",minval=1)
fromYear = input(defval =2017, title ="from year",minval=2014)
toMonth = input(defval =8, title ="to month",minval=1)
toDay = input(defval =15, title ="to day",minval=1)
toYear = input(defval =2020, title ="to year",minval=2014)
rsiSource = input(title="RSI Source", type=input.source, defval=close)
rsiLength = input(title="RSI Length", type=input.integer, defval=5)
rsiOverbought = input(title="RSI Overbought Level", type=input.integer, defval=80)
rsiOversold = input(title="RSI Oversold Level", type=input.integer, defval=20)
//Definitions
shortMa = sma(close,32)
longMa = sma(close, 50)
rsiValue = rsi(rsiSource, rsiLength)
isOverbought = rsiValue >= rsiOverbought
isOversold = rsiValue <= rsiOversold
plot(na)
//
// Plot signals to chart
plotshape(isOverbought, title="Overbought", location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, text="OB")
plotshape(isOversold, title="Oversold", location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, text="OS")
//Logic
timeInRange =(time > timestamp(fromYear, fromMonth, fromDay, 00, 00)) and (time < timestamp(toYear, toMonth, toDay, 23,59))
longSignal = crossover(shortMa, longMa)and timeInRange and isOversold
shortSignal = crossover(longMa,shortMa) and timeInRange and isOverbought
//Positions
strategy.entry(id="longPosition", long=true, qty=0.1, when=longSignal)
strategy.entry(id="shortPosition", long=false, qty=0.05, when=shortSignal)