RSI Reversal Trading Strategy

Author: ChaoZhang, Date: 2023-11-14 16:49:02
Tags:

img

Overview

The RSI reversal trading strategy is a quantitative trading strategy that identifies overbought and oversold conditions using the Relative Strength Index (RSI) indicator and enters long or short trades at reversal points. This strategy sets RSI overbought and oversold threshold levels and goes short when RSI enters the overbought zone and goes long when RSI enters the oversold zone to capture price reversals.

Strategy Logic

The strategy is based on the following core logic:

  1. RSI can reflect whether the current market is overbought or oversold. RSI measures the relative momentum of upside vs downside by calculating the ratio of average up changes to average down changes over a period of time.

  2. When RSI enters the overbought zone (usually regarded as RSI above 70), it indicates strong upside momentum. There will be more traders long holding bullish positions and the room for continuing upside is limited. The price may reverse downwards to correct the overbought condition.

  3. When RSI enters the oversold zone (usually below 30), it indicates strong downside momentum. There will be more traders short holding bearish positions and the room for continuing downside is limited. The price may reverse upwards to correct the oversold condition.

  4. Therefore, we can set the RSI overbought threshold at 90 and oversold threshold at 10. Go short when RSI enters the overbought zone and go long when RSI enters the oversold zone to capture reversals.

Specifically, the strategy logic is:

  1. Calculate the RSI indicator value, using close price as the RSI source, with a length of 2 periods.

  2. When RSI crosses above 90, it indicates entering the overbought zone, go short. When RSI crosses below 10, it indicates entering the oversold zone, go long.

  3. Set a stop loss for each trade. Long stop at lowest low price, short stop at highest high price.

  4. Set a trailing stop for each trade. If RSI continues into more extreme overbought/oversold levels, adjust the trailing stop to give more room.

  5. Consider taking profit when RSI reverts back to neutral zone around 50.

  6. If no reversal after 3 bars, close trade to avoid unlimited loss.

Advantages

The RSI reversal strategy has the following advantages:

  1. Using RSI to identify overbought/oversold conditions can effectively capture market reversal points. RSI is accurate in judging extremes and has high reversal success rate.

  2. Reversal strategies have systematic edge of continuing to follow trends. It can go short on overbought and long on oversold timely to avoid being trapped.

  3. The stop loss mechanism effectively controls the loss on individual trades. Even if reversal fails, loss is contained within certain range.

  4. Trailing stop can flexibly adjust stop distance based on continued price movement, balancing between keeping stop triggered and capturing more price difference.

  5. Forced exit after fixed bars ensures trades without timely reversal will not lead to unlimited losses.

  6. Adjustable RSI parameters can adapt the strategy to different markets.

Risks

The strategy also has the following risks:

  1. As a technical indicator strategy, RSI reversal performance may have curve fitting bias. Real trading reversal success rate may be lower than backtest results.

  2. Although RSI can identity overbought/oversold conditions, it cannot predict the exact reversal timing. Risk of no reversal after entry and price continues trending.

  3. RSI overbought/oversold levels may not be reasonably set. Wrong levels may lead to missing reversals or getting stopped out before reversals.

  4. Probability of price making another reversal before reaching take profit. Take profit may not get filled.

  5. Stop loss distance set unreasonably tight or too loose may render stops ineffective.

  6. Trading commissions can also impact strategy profitability.

Enhancements

The strategy can be enhanced in the following ways:

  1. Test different RSI parameters to find optimal combinations, such as RSI length, overbought/oversold threshold levels.

  2. Add more filters to avoid false reversal signals, such as combining with MACD etc to increase probability.

  3. Optimize stop loss strategy, e.g. ATR based stops, volatility adjusted distances.

  4. Optimize take profit strategy, such as moving take profit, trailing more price difference.

  5. Add machine learning models to assist judging reversals and improve success rate.

  6. Test strategy across different markets and instruments to find best parameters for real trading.

  7. Combine with trading volume, only consider reversal signals when volume surges.

Conclusion

In conclusion, the RSI reversal strategy takes advantage of RSI’s strength in identifying overbought and oversold market conditions and trades at reversal points, providing decent systematic returns. But it also has risks that need to be addressed through RSI parameters and stop/take profit optimization, and filtering with other indicators. If executed properly, RSI reversal can form an effective component in a quantitative trading system.


/*backtest
start: 2023-11-06 00:00:00
end: 2023-11-13 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
// Copyright (c) 2021-present, RicMos
//study("RSI2 Sell Strategy, overlay=true)

//------------------------------------------USER VARIABLE DEFINITIONS --------------------------------------
var float lots = 0.1
//var float fixed_commission = 0.6 // forex pairs commission  value USD per position size two sides
var float fixed_commission = 10 // BTC commission value USD per position size two sides
//var float money = 10000 //forex pairs position size
var float money = 0.3333 //BTC position size



strategy(title="RSI2 Sell Strategy", commission_type=strategy.commission.cash_per_order, calc_on_every_tick =true, commission_value = fixed_commission/2, overlay=true, default_qty_value= lots*100000, initial_capital=1000, currency = "USD", calc_on_order_fills = false)
len = input(2, minval=1, title="RSI Length")
src = input(close, "RSI Source", type = input.source)
upRsi = rma(max(change(src), 0), len)
downRsi = rma(-min(change(src), 0), len)
rsi = downRsi == 0 ? 100 : upRsi == 0 ? 0 : 100 - (100 / (1 + upRsi / downRsi))
var color buyColor = color.blue
var color sellColor = color.red


plotshape(rsi <= 10 ? low : na, title="Arrow Up", style=shape.triangleup, location=location.belowbar, size=size.tiny, color=buyColor)
plotshape(rsi >= 90 ? high : na, title="Arrow Down", style=shape.triangledown, location=location.abovebar, size=size.tiny, color=sellColor)


// long = rsi <= 10 
// var float longsl = 0
// var int long_ts_points = 0

// if long
//     longsl:= low
//     long_ts_points := 200
    
// if rsi >= 70
//     long_ts_points := 100
// else if rsi >= 80
//     long_ts_points := 80


// plot (longsl)
// var int barsPassed = 0
// barsPassed := barssince(long)
// if long
//     strategy.entry("long", long = strategy.long, qty = 10000, stop = high)
// strategy.exit("slLo", from_entry="long", stop = longsl-0.0002, trail_points = long_ts_points )
// //strategy.close("long", when = rsi[1]>=50 and rsi < 50 , comment = "rsi under 50" )
// strategy.cancel_all(barsPassed > 3  and not long)


short = rsi >= 90 
var float shortsl = 0
var int short_ts_points = 0
//var bool stClose = 0

if short
    shortsl:= high
    short_ts_points := 200
    
if rsi <= 30
    short_ts_points := 100
    //stClose :=1
else if rsi <= 20
    short_ts_points := 80 
//else
    //stClose := 0

plot (shortsl)
var int barsPassedSh = 0
barsPassedSh := barssince(short)
if short
    strategy.entry("short", long = strategy.short, qty = money, stop = low)
strategy.exit("slSh", from_entry="short", stop = shortsl, trail_points = short_ts_points, trail_offset =20 )
//strategy.close("short", comment="rsi<30", when = stClose)


//strategy.close("long", when = rsi[1]>=50 and rsi < 50 , comment = "rsi under 50" )
strategy.cancel_all(barsPassedSh > 3  and not short)










More