The RSI range breakout strategy is a typical trend following strategy. It uses the Relative Strength Index (RSI) as the main technical indicator to look for breakout opportunities when RSI is in overbought or oversold levels, with the goal of following the trend.
The strategy mainly relies on the RSI indicator to determine overbought and oversold levels in the market. The RSI calculation formula is: RSI = (Average Up Value / (Average Up Value + Average Down Value)) x 100. The Average Up Value is the simple moving average of close-up amplitudes over the past N days. The Average Down Value is the simple moving average of close-down amplitudes over the past N days.
When RSI is higher than the overbought line (default 80), it indicates the market is in an overbought state. When RSI is lower than the oversold zone (default 35), it indicates the market is in an oversold state. The strategy looks for short opportunities when RSI breaks down the overbought line, and long opportunities when RSI breaks up the oversold zone.
Specifically, the strategy uses two SMA lines to determine the trend of the RSI indicator. When the faster SMA line breaks up the slower SMA line, while the RSI breaks through the oversold zone, go long. When the faster SMA line breaks down the slower SMA line, while the RSI breaks the overbought line, go short. The strategy also sets stop loss and take profit lines to control risks.
The RSI range breakout strategy is a typical trend following strategy overall. It determines trading signals through RSI indicator, filters signals with double SMA lines, and sets stop loss and take profit to control risks. But RSI indicator has lagging issues, and improper parameter settings also affect strategy performance. The trend following capability can be fully realized through further optimization.
/*backtest start: 2023-09-10 00:00:00 end: 2023-10-10 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 //strategy("Strategy RSI | Fadior", shorttitle="Strategy RSI", pyramiding=10, calc_on_order_fills=false, initial_capital=10000, default_qty_type=strategy.percent_of_equity, currency="USD", default_qty_value=100, overlay=false) len = input(3, minval=1, title="RSI Length") threshLow = input(title="Treshold Low", defval=35) threshHigh = input(title="Treshold High", defval=80) rsiLength1 = input(title="RSI Smoothing 1", defval=3) rsiLength2 = input(title="RSI Smoothing 2", defval=5) SL = input(title="Stop loss %", type=float, defval=.026, step=.001) TP = input( defval=300) // 3 40 70 2 // 14 40 70 2 16 0.05 50 src = close up = rma(max(change(src), 0), len) down = rma(-min(change(src), 0), len) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) plot(sma(rsi,rsiLength2), color=orange) plot(sma(rsi,rsiLength1), color=green) band1 = hline(threshHigh) band0 = hline(threshLow) fill(band1, band0, color=purple, transp=90) strategy = input(type=bool, title="Long only ?", defval=true) strategy.risk.allow_entry_in(strategy ? strategy.direction.long : strategy.direction.all) longCondition = sma(rsi,rsiLength1) < threshLow and sma(rsi,rsiLength2) > sma(rsi,rsiLength2)[1] if (longCondition) strategy.entry("Long", strategy.long) //, qty=10) strategy.exit("Close Long", "Long", stop=src-close*SL, profit=TP) shortCondition = sma(rsi,rsiLength1) > threshHigh and sma(rsi,rsiLength2) < sma(rsi,rsiLength2)[1] if (shortCondition) strategy.entry("Short", strategy.short) //, qty=10) strategy.exit("Close Short", "Short") //, stop=src-close*SL, profit=TP)