RSI Overbought/Oversold Zone Momentum Breakout Quantitative Strategy

RSI SMA EMA TP/SL 风险管理 动量突破 超买超卖 趋势过滤器
Created on: 2025-04-29 09:10:11 Modified on: 2025-04-29 09:10:11
Copy: 0 Number of hits: 413
avatar of ianzeng123 ianzeng123
2
Follow
319
Followers

 RSI Overbought/Oversold Zone Momentum Breakout Quantitative Strategy  RSI Overbought/Oversold Zone Momentum Breakout Quantitative Strategy

Overview

The RSI Overbought/Oversold Zone Momentum Breakout Quantitative Strategy is a trading system based on the Relative Strength Index (RSI) that focuses on capturing market momentum changes and price breakouts. The core of this strategy is identifying overbought and oversold areas through an adjusted RSI indicator, combined with EMA and SMA filters to enhance signal quality, and implementing strict time window and daily trade limits to control risk. This strategy employs clear take-profit targets and stop-loss mechanisms, suitable for intraday and short-term traders.

Strategy Principles

The core principle of this strategy is to capture RSI indicator breakouts from neutral zones into overbought or oversold areas, which typically signals potential price trend changes. The specific implementation is as follows:

  1. Adjusted RSI Calculation: Standard 14-period RSI value minus 50, making the indicator fluctuate between -50 and +50, with the zero line as a neutral reference point.

  2. Dynamic Threshold Setting: Sets different center values and fluctuation ranges based on market trends, automatically adjusting signal trigger thresholds in bullish and bearish market environments.

    • Bullish center value: +5 (when price is above SMA200)
    • Bearish center value: -5 (when price is below SMA200)
    • Fluctuation range set to ±2
  3. Signal Generation Logic:

    • Long signal: When adjusted RSI breaks above the upper threshold (center value + fluctuation range) and price is above EMA (if enabled)
    • Short signal: When adjusted RSI breaks below the lower threshold (center value - fluctuation range) and price is below EMA (if enabled)
  4. Trade Management: The strategy only executes within specified trading hours (default 9:30 to 16:00 EST) and can set a maximum number of daily trades (default 5).

  5. Risk Control: Uses fixed take-profit points (default 50 Ticks) and optional stop-loss points (default 30 Ticks) based on minimum price movement units (Ticks).

Strategy Advantages

  1. Market Environment Adaptation: Divides bull and bear markets through SMA200, dynamically adjusts RSI threshold center points, enabling the strategy to adapt to different market environments.

  2. Multiple Filtering Mechanisms: Combines EMA dynamic filtering and SMA200 trend filtering, significantly improving signal quality and reducing false breakouts.

  3. Strict Time Management: Sets trading session windows, avoiding high volatility periods at market open and close, focusing on optimal market liquidity periods.

  4. Risk Exposure Control: Prevents overtrading and overnight risk through daily trade limits and automatic close-at-session-end mechanisms.

  5. Visual Feedback System: Provides intuitive market status and performance monitoring through color-coded price bars and a visual trading panel.

  6. Flexible Parameter Configuration: All key parameters can be adjusted through input options, making the strategy adaptable to different trading instruments and timeframes.

Strategy Risks

  1. False Breakout Risk: RSI breakouts may lead to false signals, especially in sideways markets. The solution is to add confirmation conditions, such as combining price patterns or volume confirmation.

  2. Over-optimization Risk: Multiple parameter settings may lead to overfitting historical data. It is recommended to backtest under different market conditions to find robust parameter combinations.

  3. Market Environment Dependency: The strategy may perform better in strong trending markets than in oscillating markets. The current market environment should be evaluated before use, adjusting parameters or pausing trading when necessary.

  4. Fixed Take-Profit/Stop-Loss Limitations: Tick-based fixed take-profit and stop-loss points may not be suitable for all market conditions. Consider using volatility-based dynamic take-profit/stop-loss points, such as ATR multiples.

  5. Time Window Limitations: Strict trading time windows may miss quality trading opportunities outside the session. Consider setting different trading windows for different markets.

Strategy Optimization Directions

  1. Dynamic Threshold Optimization: The current strategy uses a fixed fluctuation range (±2); consider dynamically adjusting this range based on market volatility (such as ATR) to adapt to different market conditions.

  2. Volatility Filter: Add volatility filtering conditions based on ATR, avoiding trading when volatility is too low, helping to reduce false signals in sideways markets.

  3. Multi-Timeframe Confirmation: Integrate RSI signal confirmation across multiple timeframes, generating trading signals only when RSI directions are consistent across timeframes, improving signal quality.

  4. Volume Confirmation Mechanism: Add volume conditions, requiring price breakouts to be accompanied by increased volume, enhancing signal reliability.

  5. Profit Locking Mechanism: Implement dynamic trailing stops, automatically adjusting stop-loss positions as price moves favorably, locking in partial profits.

  6. Entry Optimization: Add market structure conditions (such as support/resistance levels), entering only when key price levels break, improving win rates.

  7. Adaptive Parameters: Implement mechanisms to automatically adjust RSI length and EMA periods based on market conditions, making the strategy more adaptive.

Summary

The RSI Overbought/Oversold Zone Momentum Breakout Quantitative Strategy is a well-structured trading system that provides traders with an effective tool for capturing market momentum shifts by combining RSI momentum breakouts, trend filtering, and strict risk management. The uniqueness of this strategy lies in its dynamic threshold adjustment mechanism, which automatically adjusts signal generation standards based on overall market trends.

The strategy’s multiple filtering mechanisms and strict trading rules effectively reduce false signals, while flexible parameter configuration allows it to adapt to different trading instruments and market conditions. However, users should recognize the inherent limitations of RSI breakout strategies, especially their performance in sideways markets.

Through the suggested optimization directions, such as dynamic threshold adjustment, multi-timeframe confirmation, and volatility filtering, the robustness and adaptability of this strategy can be further enhanced. Overall, this is a strategy framework that balances signal quality and risk control, suitable for medium to short-term traders in intraday operations.

Strategy source code
/*backtest
start: 2025-04-21 00:00:00
end: 2025-04-28 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/

//@version=6
strategy('RSI SR OB Breakouts Strategy PRO (coffeshopcrypto)', overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=15, max_bars_back=200, max_boxes_count=200, precision=2)

// === Inputs ===
show_hide_boxes = input.bool(true, 'Show Ranges')
show_hide_orderblocks = input.bool(true, 'Show Orderblocks')
use_breakout_colors = input.bool(true, title="Use Breakout Bar Colors")

rsi_len = input.int(14, title="RSI Length", minval=4, group="Risk Management")

// --- Risk Management ---
takeProfitPoints = input.int(50, title="Take Profit (Ticks)", group="Risk Management")
useStopLossMode = input.bool(false, title="Use Stop Loss Instead of Only TP?", group="Risk Management")
stopLossPoints = input.int(30, title="Stop Loss (Ticks)", group="Risk Management")

// --- Time Preferences ---
startTradeHour = input.int(9, title="Trading Start Hour (EST)", minval=0, maxval=23, group="Time Preferences")
startTradeMinute = input.int(30, title="Trading Start Minute (EST)", minval=0, maxval=59, group="Time Preferences")
endTradeHour = input.int(16, title="Trading End Hour (EST)", minval=0, maxval=23, group="Time Preferences")
endTradeMinute = input.int(0, title="Trading End Minute (EST)", minval=0, maxval=59, group="Time Preferences")

// --- Trade Limit Preferences ---
useTradeLimit = input.bool(true, title="Enable Daily Trade Limit?", group="Trade Limit")
maxTradesPerDay = input.int(5, title="Max Trades Per Day", minval=1, group="Trade Limit")

// --- EMA Adjustable ---
ema_filter_enabled = input.bool(true, "Use EMA Filter?")
ema_length = input.int(50, "EMA Length", minval=2)
ema_dynamic = ta.ema(close, ema_length)

// --- SMA150 Trend Filter ---
sma200 = ta.sma(close, 150)
useBullishSettings = close > sma200

// --- Trading Panel Toggle ---
showPanel = input.bool(true, "Show Session Trading Panel?", group="Display Settings")

// === Trade Time Check (EST Time) ===
tradeAllowed = (hour > startTradeHour or (hour == startTradeHour and minute >= startTradeMinute)) and 
               (hour < endTradeHour or (hour == endTradeHour and minute <= endTradeMinute))

// === Trade Limit Check ===
var int tradeCount = 0
newDay = ta.change(dayofmonth) != 0
if newDay
    tradeCount := 0

canTrade = tradeAllowed and (not useTradeLimit or tradeCount < maxTradesPerDay)

// === Calculate RSI and thresholds ===
rsi_up = ta.rma(math.max(ta.change(close), 0), rsi_len)
rsi_down = ta.rma(-math.min(ta.change(close), 0), rsi_len)
_rsi = rsi_down == 0 ? 100 : rsi_up == 0 ? 0 : 100 - 100 / (1 + rsi_up / rsi_down)
adjustedRSI = _rsi - 50

bullish_center = 5
bearish_center = -5
spread = 2
auto_rsi_center = useBullishSettings ? bullish_center : bearish_center
momentum_upper_threshold = auto_rsi_center + spread
momentum_lower_threshold = auto_rsi_center - spread

pricebarColor = adjustedRSI > momentum_upper_threshold ? color.rgb(37, 155, 41) : adjustedRSI < momentum_lower_threshold ? color.rgb(223, 48, 48) : color.gray

// === Signal Conditions ===
longCondition = adjustedRSI > momentum_upper_threshold and (not ema_filter_enabled or close > ema_dynamic)
shortCondition = adjustedRSI < momentum_lower_threshold and (not ema_filter_enabled or close < ema_dynamic)

// === Fresh Triggers Only ===
var bool longTrigger = false
var bool shortTrigger = false

longTrigger := longCondition and not longCondition[1]
shortTrigger := shortCondition and not shortCondition[1]

// === Trade Management with Reversals ===
var int winsToday = 0
var int lossesToday = 0

if (canTrade)
    if (longTrigger)
        if (strategy.position_size < 0)
            strategy.close("Short", comment="Reverse to Long")
        if (strategy.position_size <= 0)
            strategy.entry("Long", strategy.long)
            tradeCount += 1

    if (shortTrigger)
        if (strategy.position_size > 0)
            strategy.close("Long", comment="Reverse to Short")
        if (strategy.position_size >= 0)
            strategy.entry("Short", strategy.short)
            tradeCount += 1

// === Attach Exits After Entry ===
if (strategy.position_size > 0)
    longTakeProfit = strategy.position_avg_price + (takeProfitPoints * syminfo.mintick)
    longStopLoss = strategy.position_avg_price - (stopLossPoints * syminfo.mintick)
    if useStopLossMode
        strategy.exit("Long Exit", from_entry="Long", limit=longTakeProfit, stop=longStopLoss)
    else
        strategy.exit("Long TP Only", from_entry="Long", limit=longTakeProfit)

if (strategy.position_size < 0)
    shortTakeProfit = strategy.position_avg_price - (takeProfitPoints * syminfo.mintick)
    shortStopLoss = strategy.position_avg_price + (stopLossPoints * syminfo.mintick)
    if useStopLossMode
        strategy.exit("Short Exit", from_entry="Short", limit=shortTakeProfit, stop=shortStopLoss)
    else
        strategy.exit("Short TP Only", from_entry="Short", limit=shortTakeProfit)

// === Track wins/losses ===
if (strategy.closedtrades > 0)
    if (strategy.closedtrades.profit(strategy.closedtrades - 1) > 0)
        winsToday += 1
    else
        lossesToday += 1

// === Auto Close all trades if time window ended ===
if (not tradeAllowed)
    strategy.close_all(comment="Session End Auto Close")

// === Plotting ===
plot(adjustedRSI, title="Adjusted RSI", color=color.rgb(255, 235, 59))
plot(ema_dynamic, title="Dynamic EMA", color=color.blue)
plot(sma200, title="SMA 200", color=color.gray)
hline(0, color=color.white)

barcolor(use_breakout_colors ? pricebarColor : na)

// === Trading Panel ===
if showPanel
    label.new(x=bar_index, y=high, text="Wins: " + str.tostring(winsToday) + " | Losses: " + str.tostring(lossesToday), color=color.black, style=label.style_label_left, size=size.small)