This strategy is an intelligent trading system based on the Relative Strength Index (RSI), combining various moving averages and Bollinger Bands to time trades by identifying market overbought and oversold zones. The core mechanism relies on RSI breakthrough and pullback signals, complemented by different types of moving averages for trend confirmation, enabling efficient swing trading. The strategy demonstrates strong adaptability and can be adjusted for different market conditions.
The strategy utilizes a 14-period RSI as its core indicator, generating trading signals by monitoring RSI crossovers with key levels at 30 and 70. A long signal is triggered when RSI breaks above 30, indicating a shift from oversold to bullish conditions. A closing signal is generated when RSI falls below 70, suggesting a transition from overbought to bearish conditions. The strategy incorporates various moving averages (SMA, EMA, SMMA, WMA, VWMA) and Bollinger Bands as supplementary indicators for trend confirmation and volatility assessment.
This strategy captures market overbought and oversold opportunities through the RSI indicator, confirming signals with multiple technical indicators, demonstrating strong practicality and reliability. The strategy design thoroughly considers risk control and can adapt to various market environments through parameter optimization and indicator combinations. Traders are advised to conduct comprehensive backtesting before live implementation and adjust parameters according to specific market characteristics.
/*backtest start: 2019-12-23 08:00:00 end: 2024-12-10 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy(title="Demo GPT - Relative Strength Index", shorttitle="RSI Strategy", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_value=0.1, slippage=3) // Inputs rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings") rsiSourceInput = input.source(close, "Source", group="RSI Settings") calculateDivergence = input.bool(false, title="Calculate Divergence", group="RSI Settings", tooltip="Calculating divergences is needed in order for divergence alerts to fire.") // RSI Calculation change = ta.change(rsiSourceInput) up = ta.rma(math.max(change, 0), rsiLengthInput) down = ta.rma(-math.min(change, 0), rsiLengthInput) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) // RSI Plots rsiPlot = plot(rsi, "RSI", color=#7E57C2) rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86) midline = hline(50, "RSI Middle Band", color=color.new(#787B86, 50)) rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86) fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill") plot(50, color=na, editable=false, display=display.none) // Moving Averages maTypeInput = input.string("SMA", "Type", options=["None", "SMA", "SMA + Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Moving Average") maLengthInput = input.int(14, "Length", group="Moving Average") bbMultInput = input.float(2.0, "BB StdDev", minval=0.001, maxval=50, step=0.5, group="Moving Average") enableMA = maTypeInput != "None" isBB = maTypeInput == "SMA + Bollinger Bands" // MA Calculation ma(source, length, MAtype) => switch MAtype "SMA" => ta.sma(source, length) "SMA + Bollinger Bands" => ta.sma(source, length) "EMA" => ta.ema(source, length) "SMMA (RMA)" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) smoothingMA = enableMA ? ma(rsi, maLengthInput, maTypeInput) : na smoothingStDev = isBB ? ta.stdev(rsi, maLengthInput) * bbMultInput : na plot(smoothingMA, "RSI-based MA", color=color.yellow, display=enableMA ? display.all : display.none) bbUpperBand = plot(smoothingMA + smoothingStDev, title="Upper Bollinger Band", color=color.green, display=isBB ? display.all : display.none) bbLowerBand = plot(smoothingMA - smoothingStDev, title="Lower Bollinger Band", color=color.green, display=isBB ? display.all : display.none) fill(bbUpperBand, bbLowerBand, color=isBB ? color.new(color.green, 90) : na, title="Bollinger Bands Background Fill", display=isBB ? display.all : display.none) // Trade Logic longCondition = ta.crossover(rsi, 30) exitCondition = ta.crossunder(rsi, 70) // Start Date & End Date startDate = input(timestamp("2018-01-01 00:00"), "Start Date", group="Date Range") endDate = input(timestamp("2069-12-31 23:59"), "End Date", group="Date Range") inDateRange = true // Execute Trades if (longCondition and inDateRange) strategy.entry("Long", strategy.long) if (exitCondition and inDateRange) strategy.close("Long")