RSI and Bollinger Bands Fusion Trading Strategy for LTC

Author: ChaoZhang, Date: 2024-02-06 10:48:03
Tags:

img

Overview

This strategy combines the Relative Strength Index (RSI) and Bollinger Bands to implement an automated strategy that can buy and sell Litecoin (LTC). It is suitable for the LTC/USD trading pair and runs in the Bitfinex cryptocurrency exchange.

Strategy Logic

The strategy mainly relies on the following two indicators for trading decisions:

  1. Relative Strength Index (RSI): It reflects the magnitude and speed of price changes to determine if an asset is overbought or oversold. RSI below 20 is seen as oversold while above 80 is seen as overbought.

  2. Bollinger Bands: It contains three lines - middle line, upper band and lower band. The middle line is the n-day moving average. The upper and lower bands are middle line ± 2 standard deviation of prices over last n days. Price near upper band suggests overbought condition and near lower band suggests oversold condition.

According to these two indicators, the trading rules are:

Buy Signal: When RSI crosses above 20 from low zone, it indicates an oversold condition that may reverse. If price also breaks below lower band of Bollinger Bands, a buy signal is triggered.

Sell Signal: When RSI crosses below 80 from high zone, it indicates an overbought condition that may reverse. If price also breaks above upper band of Bollinger Bands, a sell signal is triggered.

As we can see, the strategy considers both market overbought/oversold condition and price breakout to generate trading signals.

Advantages

The main advantages of this strategy are:

  1. Combines RSI and Bollinger Bands to comprehensively judge market condition, resulting in reliable signals.

  2. RSI gauges overbought/oversold levels while Bollinger Bands depict price deviation from typical distribution. The two complements each other.

  3. Considers both indicator readings and price breakout to avoid false signals during range-bound market.

  4. Reasonable parameter settings of RSI and Bollinger Bands period and thresholds based on optimization to prevent indicator failure.

  5. Specifically optimized for LTC. Performance is good based on historical data backtest. Further optimization can improve it more.

Risks

Despite the advantages, some risks exist:

  1. Both RSI and Bollinger Bands may fail, especially during abnormal market condition, leading to wrong signals and losses.

  2. Parameter optimization relies on historical data. Significant market regime change can make these parameters invalid, deteriorating strategy performance.

  3. Although two indicators are used, whipsaws may still occur during range-bound market, causing losses and opportunity cost.

  4. Trading cost is ignored in the strategy. High trading frequency and oversized position can erode profits quickly via costs.

To reduce the above risks, methods like parameter tuning, more indicators, position sizing, limiting trading frequency etc. can be adopted.

Improvement Directions

Some directions to improve the strategy:

  1. Test different RSI and Bollinger Bands parameters for better settings.

  2. Introduce position sizing rules based on account equity.

  3. Set stop loss, or use other indicators to determine stop loss and take profit levels to limit max drawdown.

  4. Consider slippage to adjust parameters and stop loss in live trading.

  5. Add more factors like volatility index, volume etc to form a multifactor model for higher accuracy.

  6. Design adaptive mechanisms according to different LTC market regimes and cycles to dynamically adjust strategy parameters.

Conclusion

This strategy judges overbought/oversold levels first and then combines with breakout to generate trading signals, making it suitable for LTC. But risks like indicator failure, regime change and trading costs should be watched out. There are many directions for improvement and further optimization can lead to better results.


/*backtest
start: 2024-01-29 00:00:00
end: 2024-02-05 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("LTCUSD BB + RSI 30MIN,", shorttitle="LTCUSD BBRSI 30MIN ", overlay=true)
     
     // Strategy Tester Start Time
sYear = input(2019, title = "Start Year")
sMonth = input(01, title = "Start Month", minval = 01, maxval = 12)
sDay = input(01, title = "Start Day", minval = 01, maxval = 31)
sHour = input(00, title = "Start Hour", minval = 00, maxval = 23)
sMinute = input(00, title = "Start Minute", minval = 00, maxval = 59)
startTime = true


///////////// RSI
RSIlength = input(5,title="RSI Period Length") 
RSIoverSold = input(20, minval=1,title="RSIL")
RSIoverBought = input(80, minval=1,title="RSIh")
price = open
vrsi = rsi(price, RSIlength)


///////////// Bollinger Bands
BBlength = input(60, minval=1,title="Bollinger Period Length")
BBmult = input(2.0, minval=0.001, maxval=50,title="Bb")
BBbasis = sma(price, BBlength)
BBdev = BBmult * stdev(price, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev
source = close
buyEntry = crossover(source, BBlower)
sellEntry = crossunder(source, BBupper)
plot(BBbasis, color=aqua,title="Bollinger Bands SMA Basis Line")
p1 = plot(BBupper, color=silver,title="Bollinger Bands Upper Line")
p2 = plot(BBlower, color=silver,title="Bollinger Bands Lower Line")
fill(p1, p2)


///////////// Colors
switch1=input(true, title="Enable Bar Color?")
switch2=input(true, title="Enable Background Color?")
TrendColor = RSIoverBought and (price[1] > BBupper and price < BBupper) and BBbasis < BBbasis[1] ? red : RSIoverSold and (price[1] < BBlower and price > BBlower) and BBbasis > BBbasis[1] ? green : na
barcolor(switch1?TrendColor:na)
bgcolor(switch2?TrendColor:na,transp=50)


///////////// RSI + Bollinger Bands Strategy
if (not na(vrsi))

    if (crossover(vrsi, RSIoverSold) and crossover(source, BBlower))
        strategy.entry("RSI_BB_L", strategy.long and startTime, stop=BBlower,  comment="RSI_BB_L")
    else
        strategy.cancel(id="RSI_BB_L")
        
    if (crossunder(vrsi, RSIoverBought) and crossunder(source, BBupper))
        strategy.entry("RSI_BB_S", strategy.short and startTime, stop=BBupper,  comment="RSI_BB_S")
    else
        strategy.cancel(id="RSI_BB_S")

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

More