The core idea of this strategy is to combine the RSI indicator and SMA moving averages to implement position trading in trends. When the RSI indicator shows overbought or oversold conditions, it opens or closes long or short positions according to the crossover signals of the SMA moving averages. The strategy aims to discover short-term reversal opportunities to make profits.
This strategy uses the RSI indicator to determine the timing of trend reversal when overbought or oversold, with RSI values above 70 indicating overbought and below 30 indicating oversold conditions. It also uses the crossover of fast and slow SMA lines to determine the trend direction, with the fast line crossing above the slow line being a bullish signal and the fast line crossing below the slow line being a bearish signal.
When RSI is above 50 and the fast SMA crosses above the slow SMA, it opens a long position. When RSI is below 50 and the fast SMA crosses below the slow SMA, it opens a short position. When a long position is already open, if RSI falls below 50 and the fast SMA crosses below the slow SMA, it will close the long and open a short position. When a short position is already open, if RSI rises above 50 and the fast SMA crosses above the slow SMA, it will close the short and open a long position.
The main trading logic of this strategy includes:
Calculating the RSI indicator, with a length of 14
Calculating the fast SMA, with a length of 100
Calculating the slow SMA, with a length of 150
RSI > 50 and fast SMA crossing above slow SMA gives long signal
RSI < 50 and fast SMA crossing below slow SMA gives short signal
Opening and closing long/short positions based on the signals
This strategy has the following advantages:
Combining trend and reversal indicators can capture short-term reversal opportunities
RSI indicator can effectively identify overbought and oversold conditions
SMA crossover can reliably determine trend direction
The strategy logic is simple and clear, easy to understand and implement
Backtest results show decent returns even in a bear market
Uses fixed position sizing, no need for frequent adjustment
This strategy also has some risks:
Failed reversal risk. RSI reversal signals are not always reliable, false breakouts may cause losses.
Unclear trend. Trading signals from SMA crossover may be disrupted by mid-term trend reversals.
Fee impact. Frequent trading can be significantly affected by fees, eating into profits.
Parameter optimization. RSI length, SMA periods need continual testing and tuning.
Whipsaw risk. Strategy drawdown can be sizable, need psychological preparation.
To address these risks, the following measures can be taken:
Add other filters to improve signal quality
Adjust position sizing according to major trend to reduce reversal failure risk
Optimize parameters to reduce trading frequency and fee impact
Use stop loss to control single trade loss
This strategy can also be optimized in the following aspects:
Test different RSI parameter combinations to find the optimal
Test different SMA period parameters to determine the best
Reduce position sizing when trend is unclear
Add other indicators like MACD, KD for signal filtering
Test different stop loss methods to find the optimal stop loss points
Optimize position sizing strategy according to market conditions
Use advanced order types for smarter stop loss and entry
Overall this is a typical short-term mean reversion strategy, utilizing the combination of RSI indicator and SMA moving averages, it can capture profit from short-term overbought and oversold reversals. The strategy has the advantage of simple logic and few parameters, but also has some reversal failure risks and trend disruption risks. Through continual testing and parameter optimization, and adding other filters, the win rate can be improved. In addition, proper use of stop loss and position sizing is also very important. In summary, this strategy is quite practical as a short-term system and is worth trying out.
/*backtest start: 2022-10-02 00:00:00 end: 2023-10-08 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Coinrule //@version=5 strategy('RSI and SMA', overlay=true, initial_capital=1000, process_orders_on_close=true, default_qty_type=strategy.percent_of_equity, default_qty_value=30, commission_type=strategy.commission.percent, commission_value=0.1) showDate = input(defval=true, title='Show Date Range') timePeriod = time >= timestamp(syminfo.timezone, 2022, 1, 1, 0, 0) notInTrade = strategy.position_size <= 0 //==================================Buy Conditions============================================ //RSI length = input(14) rsi = ta.rsi(close, length) //SMA fastEMA = ta.sma(close, 100) slowEMA = ta.sma(close, 150) plot(fastEMA, color = color.green) plot(slowEMA, color = color.blue) bullish = ta.crossover(fastEMA, slowEMA) and rsi > 50 bearish = ta.crossover(slowEMA, fastEMA) and rsi < 50 strategy.entry("Long", strategy.long, when=bullish and timePeriod) strategy.close("Exit", when=bearish) strategy.entry("Short", strategy.short, when=bearish and timePeriod) strategy.close("Exit", when=bullish)