This strategy is a swing trading system that combines the RSI indicator with Bollinger Bands. It identifies market overbought and oversold conditions while considering price positions within the Bollinger Bands for trading decisions. The strategy employs relatively relaxed RSI thresholds (overbought at 60, oversold at 40) and integrates Bollinger Band boundaries for entry and exit timing, along with a 2% profit-taking mechanism.
The core logic is based on several key components:
Buy Conditions:
Sell Conditions:
Choppy Market Risk: May generate frequent trades in sideways markets. Solution: Add moving average filters or trend confirmation mechanisms.
False Breakout Risk: Brief price breaks of Bollinger Bands may trigger false signals. Solution: Add confirmation periods or increase breakout requirements.
Market Environment Dependency: Performance may vary across different market cycles. Solution: Dynamically adjust parameters based on market characteristics.
This strategy constructs a relatively robust swing trading system through the synergy of RSI and Bollinger Bands. Its main feature is maintaining trading opportunities while controlling risk through multiple confirmation mechanisms. While there are potential risks, the strategy’s stability and reliability can be further improved through parameter optimization and additional filtering conditions. It is suitable for volatile markets but requires parameter adjustments based on specific market characteristics.
/*backtest start: 2024-12-06 00:00:00 end: 2025-01-04 08:00:00 period: 1h basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Demo GPT - Adjusted Swing Trading for SBI", overlay=true, commission_type=strategy.commission.percent, commission_value=0.1, slippage=3) // Input Parameters rsiLength = input.int(14, minval=1, title="RSI Length") rsiOverbought = input.int(60, minval=50, maxval=100, title="RSI Overbought Level") // Relaxed level rsiOversold = input.int(40, minval=0, maxval=50, title="RSI Oversold Level") // Relaxed level bbLength = input.int(20, minval=1, title="Bollinger Bands Length") bbMult = input.float(2.0, minval=0.1, maxval=5, title="Bollinger Bands StdDev Multiplier") maLength = input.int(50, minval=1, title="Moving Average Length") // RSI Calculation rsi = ta.rsi(close, rsiLength) // Bollinger Bands Calculation bbBasis = ta.sma(close, bbLength) bbDev = bbMult * ta.stdev(close, bbLength) bbUpper = bbBasis + bbDev bbLower = bbBasis - bbDev // Moving Average ma = ta.sma(close, maLength) // Buy Signal: Price near or below lower Bollinger Band AND RSI below oversold level buySignal = (close <= bbLower * 1.01) and (rsi < rsiOversold) // Sell Signal: Price near or above upper Bollinger Band OR RSI above overbought level sellSignal = (close >= bbUpper * 0.99) or (rsi > rsiOverbought) // Date Range Inputs startDate = input(timestamp("2018-01-01 00:00"), title="Start Date") endDate = input(timestamp("2069-12-31 23:59"), title="End Date") inDateRange = true // Strategy Logic if buySignal and inDateRange strategy.entry("Swing Long SBI", strategy.long) if strategy.position_size > 0 and (sellSignal or close >= strategy.position_avg_price * 1.02) strategy.close("Swing Long SBI") // Plotting plot(bbBasis, title="Bollinger Bands Basis", color=color.blue) plot(bbUpper, title="Bollinger Bands Upper", color=color.red) plot(bbLower, title="Bollinger Bands Lower", color=color.green) plot(ma, title="Moving Average", color=color.orange) hline(rsiOverbought, "RSI Overbought", color=color.red, linestyle=hline.style_dotted) hline(rsiOversold, "RSI Oversold", color=color.green, linestyle=hline.style_dotted) plot(rsi, title="RSI", color=color.purple) // Fill Bollinger Bands for Visualization fill(plot(bbUpper), plot(bbLower), title="Bollinger Bands Background", color=color.rgb(33, 150, 243, 95))