Adaptive Momentum Swing Trading System

SMA MA ENGULFING PATTERN VOLUME FILTER SWING COUNTING Risk-Reward Ratio Adaptive SL/TP SLOPE FILTER
Created on: 2025-06-25 10:44:33 Modified on: 2025-08-04 14:01:29
Copy: 0 Number of hits: 333
avatar of ianzeng123 ianzeng123
2
Follow
319
Followers

 Adaptive Momentum Swing Trading System  Adaptive Momentum Swing Trading System

Overview

The Adaptive Momentum Swing Trading System is a trend-following strategy designed for high-volatility markets. This strategy identifies entry points at the third swing in a market trend, confirmed by volume-verified engulfing candle patterns, while employing adaptive stop-loss/take-profit mechanisms and risk-based position sizing. The core concept focuses on capturing strong market continuations by only entering trades after a trend has been clearly established and structurally confirmed, avoiding the risks of early entries.

Strategy Principles

This strategy is built on multiple filters and confirmation mechanisms to ensure entries only occur in high-probability scenarios:

  1. Trend Filter: Uses a 50-period Simple Moving Average (SMA) to determine market direction. Price above SMA indicates an uptrend suitable for buys; price below SMA indicates a downtrend suitable for sells.

  2. Swing Count Logic:

    • For buys: Waits for the 3rd higher low to form
    • For sells: Waits for the 3rd lower high to form
    • Uses a 5-bar lookback window to detect highs/lows This ensures trades are not entered early in a trend, but after the trend has been confirmed through price structure.
  3. Engulfing Candle Confirmation:

    • Bullish engulfing pattern required for buys
    • Bearish engulfing pattern required for sells
    • Candle must completely engulf the previous candle (body logic)
  4. Volume Filter: Current candle volume must exceed the 20-period volume average, ensuring trades only occur with institutional participation.

  5. MA Slope Filter: Requires the slope of the 50 SMA over the last 3 candles to exceed 0.1, avoiding chop or flat trends and adding momentum confirmation.

  6. Session Filter: Trades are only executed within specific time windows to avoid overnight chop and illiquidity.

  7. Adaptive Stop Loss Mechanism:

    • Stop loss is based on the full size of the signal candle (including wick)
    • If the candle is larger than 25 points, the stop loss is reduced to half the candle size
    • This prevents oversized risk exposure during volatile moves
  8. Risk-Based Position Sizing: Dynamically calculates position size based on risk amount per trade and stop loss size, ensuring risk consistency.

Strategy Advantages

  1. Structured Entries: By waiting for the third swing, the strategy avoids chasing trends and only enters after a trend has been established and confirmed by price structure, significantly improving win rates.

  2. Multiple Confirmation Layers: Combines trend, swing count, candle pattern, volume, and momentum indicators as multiple filters, ensuring entries only when multiple signals align, reducing false signals.

  3. Adaptive Risk Management: Dynamically adjusts stop loss levels based on actual market volatility, automatically reducing stop distance during high-volatility periods to protect capital.

  4. Quantified Risk Control: Through precise calculation of position size for each trade, the strategy ensures that risk amount per trade remains consistent regardless of changing market conditions.

  5. Institutional Money Confirmation: Through the volume filter, trades are only taken when large money is participating, increasing the probability of trend continuation.

  6. Noise-Resistant Design: Time filters and minimum slope requirements help avoid poor-quality trading environments and false signals in directionless markets.

  7. Customizable Parameters: The strategy provides multiple adjustable parameters, allowing traders to optimize according to personal risk preferences and different market environments.

Strategy Risks

  1. Swing Count Reset Risk: When a signal triggers a trade, the swing counter resets, potentially causing missed subsequent signals at suboptimal times. Consider implementing a more intelligent reset mechanism or adding recognition of secondary signals.

  2. Fixed Lookback Window Limitation: Using a fixed 5-bar lookback window may perform inconsistently across different market environments. Consider implementing an adaptive lookback window that adjusts automatically based on market volatility.

  3. Over-Reliance on Single Timeframe: Operating solely on a 5-minute chart may miss important structures from higher timeframes. Consider adding multi-timeframe analysis to improve entry quality.

  4. Fixed Profit Ratio: The fixed risk-reward ratio (2.2) may not be suitable for all market environments. During low-volatility periods, this might lead to unrealistic targets; during high-volatility periods, it may take profits too early. Consider dynamically adjusting take-profit levels based on ATR or market volatility.

  5. Candle Size Threshold Risk: The large candle handling logic (25-point threshold) is a fixed value that may not adapt to all market environments. Recommend using relative values (such as percentage of ATR) instead of fixed points.

  6. Session Limitation Risk: The fixed session filter may miss important market opportunities. Consider dynamically adjusting trading time windows based on actual volatility and liquidity conditions.

Optimization Directions

  1. Adaptive Parameter Optimization:

    • Convert fixed parameters (such as MA length, lookback window, slope threshold) to dynamic parameters that automatically adjust based on market volatility
    • Implement ATR-based adaptive stop-loss and take-profit mechanisms instead of fixed ratios
    • Develop a market state detection system that automatically adjusts parameters in different market environments (trending, ranging, breakout)
  2. Multi-Timeframe Integration:

    • Add higher timeframe trend confirmation to ensure trade direction aligns with larger trends
    • Implement cross-timeframe support/resistance identification to improve entry points and stop placement
    • Develop adaptive timeframe selection mechanism that automatically selects the optimal operating timeframe based on volatility
  3. Advanced Swing Analysis:

    • Improve the swing counting mechanism to differentiate between weak and strong swings
    • Add a swing strength scoring system to prioritize more structured swings
    • Implement swing failure detection to identify trend reversal signals early
  4. Intelligent Money Management Upgrade:

    • Develop an adaptive risk management system based on account volatility
    • Implement consecutive win/loss money management adjustment mechanism
    • Add automatic compounding system based on trading performance
  5. Statistical Learning Improvements:

    • Implement a trade log analysis system to identify best-performing market conditions
    • Develop conditional probability models based on historical performance to optimize entry timing
    • Add machine learning modules to predict signal quality and filter low-probability trades
  6. Execution Optimization:

    • Develop smart entry logic supporting scaled entries to optimize average entry price
    • Implement price-action-based trailing stop system to protect profits
    • Add partial profit-taking mechanism to automatically reduce position size at different price targets

Summary

The Adaptive Momentum Swing Trading System is a well-designed trend-following strategy that enhances trade quality through multiple filters and confirmation mechanisms. Its core strengths lie in strict entry conditions, adaptive risk management, and structure-based swing identification capabilities. The strategy effectively avoids false breakouts and premature entries by waiting for the third swing and volume-confirmed engulfing patterns, while ensuring risk control through dynamic position sizing.

While already quite refined, there remains room for improvement, particularly in parameter adaptivity, multi-timeframe analysis, and advanced money management. By implementing the suggested optimization measures, especially introducing ATR-based dynamic parameters and multi-timeframe confirmation, the strategy can further improve its robustness and profitability across different market environments.

Most importantly, traders should understand that the philosophy of this strategy is to capture high-probability continuation opportunities in established trends rather than predicting turning points. By patiently waiting for multiple conditions to align and strictly adhering to risk management rules, this strategy can serve as a powerful trading system.

Strategy source code
/*backtest
start: 2025-01-01 00:00:00
end: 2025-05-12 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BNB_USDT"}]
*/

// @version=6
strategy("US30 Stealth Strategy", overlay=true)


// === USER INPUTS ===
maLen = input.int(50, "Trend MA Length")
volMaLen = input.int(20, "Volume MA Length")
hlLookback = input.int(5, "Lookback for High/Low Detection")
rrRatio = input.float(2.2, "Risk-to-Reward Ratio", step=0.1)
maxCandleSize = input.float(30.0, "Max Candle Size (pips/points)")
pipValue = input.float(1.0, "Pip Value (USD per pip/point)")
riskAmount = input.float(500.0, "Risk Per Trade (USD)")
largeCandleThreshold = input.float(25.0, "Threshold for large candles")
maSlopeLen = input.int(3, "MA Slope Lookback Bars")
minSlope = input.float(0.1, "Min Slope Threshold")


// === TREND DETECTION ===
ma = ta.sma(close, maLen)
slope = ma - ma[maSlopeLen]
isSlopeUp = slope > minSlope
isSlopeDown = slope < -minSlope
isDownTrend = close < ma and isSlopeDown
isUpTrend = close > ma and isSlopeUp


// === COUNTERS ===
var int lhCount = 0
var int hlCount = 0


// === LOWER HIGH DETECTION ===
isLowerHigh = high < ta.highest(high[1], hlLookback)
if isLowerHigh
    lhCount += 1
    hlCount := 0


// === HIGHER LOW DETECTION ===
isHigherLow = low > ta.lowest(low[1], hlLookback)
if isHigherLow
    hlCount += 1
    lhCount := 0


// === ENGULFING DETECTIONS ===
bearEng = (close < open) and (close < open[1]) and (open > close[1]) and (close <= open[1]) and (open >= close[1])
bullEng = (close > open) and (close > open[1]) and (open < close[1]) and (close >= open[1]) and (open <= close[1])


// === VOLUME FILTER ===
volMA = ta.sma(volume, volMaLen)
volOK = volume > volMA


// === TIME FILTER (Oman 2AM–11PM = UTC 22:00–19:00) ===
inSession = (hour >= 22 or hour < 19)


// === CANDLE SIZE & SL LOGIC ===
rawCandleSize = high - low
useHalfCandle = rawCandleSize > largeCandleThreshold
slSize = useHalfCandle ? rawCandleSize / 2 : rawCandleSize
validSize = rawCandleSize <= maxCandleSize


// === SIGNAL CONDITIONS ===
sellSig = inSession and isDownTrend and (lhCount == 3) and bearEng and volOK and validSize
buySig  = inSession and isUpTrend and (hlCount == 3) and bullEng and volOK and validSize


// === RISK-CALCULATED POSITION SIZE ===
positionSize = riskAmount / (slSize * pipValue)


// === SL/TP LEVELS ===
bearSL = close + slSize
bearTP = close - rrRatio * slSize


bullSL = close - slSize
bullTP = close + rrRatio * slSize


// === EXECUTIONS ===
if sellSig
    strategy.entry("Sell", strategy.short, qty=positionSize)
    strategy.exit("TP/SL Sell", from_entry="Sell", stop=bearSL, limit=bearTP)
    lhCount := 0


if buySig
    strategy.entry("Buy", strategy.long, qty=positionSize)
    strategy.exit("TP/SL Buy", from_entry="Buy", stop=bullSL, limit=bullTP)
    hlCount := 0