I’ve written a TradingView script but it filters using an MA rather than the RSI, as in your strategy. Play with it in a demo account if you think it has merit.
No commissions or slippage has been accounted for. Someone with Pinescript chops should look at it to make sure I have not screwed up anywhere. I could not get the alerts to show and the debugging mechanisms leave a lot to be desired. Perhaps it’s my lack of knowledge of Pinescript.
Here is the strategy graph for EURUSD 1H (Oanda). It does ok with AUDUSD 1H, with a lower profit and higher drawdown. It does not fare too well on other timeframes or on most other pairs. On EURUSD however, if you use prudent trade management, it might do well and will smooth out the curve too.
Once you get the script into your TradingView account you can also adjust the script parameters and input values to suit your needs. If you comment out the last “plot” statement then you will be able to view the 3 MAs used in the strategy, on the graph, along with the buy and sell indicators produced by the strategy.
//@version=4
strategy(“RSI MA Crossover Strategy”, overlay=true)
// Inputs
lot_size = input( 1000000 ) // 10 Std Lots (1 std lot per $10,000)
fast_ma_len = input( 7 ) // 7
slow_ma_len = input( 7 ) // 7
trend_ma_len = input( 50 ) // 50
smoothing = input( 3 ) // 3
// MA Computation
ma_fast = wma(wma(close,smoothing), fast_ma_len) // ema = exponential | wma = weighted | hma = hull
ma_slow = wma(wma(open,smoothing), slow_ma_len)
trend_ma = wma (close, trend_ma_len)
plot (ma_fast, color=color.blue)
plot (ma_slow, color=color.red)
plot (trend_ma, color=color.gray)
// Alerts
plotchar (ma_fast, “Fast MA”, “”, location = location.top)
plotchar (ma_slow, “Slow MA”, “”, location = location.top)
plotchar (trend_ma, “Trend MA”, “”, location = location.top)
// if Fast MA crosses over Slow MA and Anchor MA slopes upward and MAs are stacking -> BUY
alertcondition ( crossover(ma_fast, ma_slow) and (trend_ma >= trend_ma[2]) and (ma_fast[2] > trend_ma), "MA X Over - ", “Buy {{ticker}}” )
if ( crossover(ma_fast, ma_slow) and (trend_ma >= trend_ma[2]) and (ma_fast[2] > trend_ma) )
strategy.entry(“RsiLE”, strategy.long, qty=lot_size, comment=“RsiLE”)
// if Fast MA crosses under Slow MA and Anchor MA slopes downward and MAs are stacking -> SELL
alertcondition ( crossunder(ma_fast, ma_slow) and (trend_ma <= trend_ma[2]) and (ma_fast[2] < trend_ma), "MA X Under - ", “Short {{ticker}}” )
if ( crossunder(ma_fast, ma_slow) and (trend_ma <= trend_ma[2]) and (ma_fast[2] < trend_ma) )
strategy.entry(“RsiSE”, strategy.short, qty=lot_size, comment=“RsiSE”)
plot(strategy.equity, title=“equity”, color=color.red, linewidth=2, style=plot.style_areabr)