Momentum Trend Recognition with Adaptive Volatility ATR Integrated Quantitative Trading Strategy
FMZQuant

FMZQuant @fmzquant

Joined:
Apr 25, 2024

Momentum Trend Recognition with Adaptive Volatility ATR Integrated Quantitative Trading Strategy

Publish Date: May 30
1 1

Image description

Image description

Overview
The ChopFlow ATR Scalp Strategy is an efficient short-term trading framework designed for rapid market fluctuations. This strategy cleverly combines trend clarity recognition, volume confirmation, and adaptive exit mechanisms to provide traders with precise, actionable trading signals, avoiding the lag and confusion brought by traditional indicators. The strategy works primarily through three core components: first, using the Choppiness Index (CI) to filter for directional momentum; second, confirming signal validity through On-Balance Volume (OBV) compared to its moving average; and finally, automatically adjusting stop-loss and target levels based on the Average True Range (ATR). This approach is particularly suitable for short-term traders who need clean, timely entry signals, helping them avoid market noise and capture core trend opportunities.

Strategy Principles
Through in-depth code analysis, we can clearly understand the core operating principles of this strategy:

Trend Strength Assessment: The strategy uses the Choppiness Index (CI) to evaluate market trend strength. Lower CI values indicate more pronounced trends; higher CI values indicate consolidation phases. The specific calculation is as follows:

tr = ta.tr(true)
sumTR = math.sum(tr, chopLength)
range_ = ta.highest(high, chopLength) - ta.lowest(low, chopLength)
chop = 100 * math.log(sumTR / range_) / math.log(chopLength)
Enter fullscreen mode Exit fullscreen mode

Volume Confirmation: The strategy uses On-Balance Volume (OBV) and its Simple Moving Average (SMA) to confirm whether price trends have sufficient volume support. OBV is a cumulative indicator where daily volume is counted as positive when prices rise and negative when prices fall.

obv = ta.cum(math.sign(ta.change(close)) * volume)
obvSma = ta.sma(obv, obvSmaLength)
Enter fullscreen mode Exit fullscreen mode

Trading Session Filter: The strategy includes a session filter to ensure trades are executed only during specified trading hours, avoiding low liquidity periods and overnight gap risks.

inSession = not na(time(timeframe.period, sessionInput))
Enter fullscreen mode Exit fullscreen mode

Entry Conditions: The long condition occurs when within a trading session, the Choppiness Index is below the threshold (indicating a strong trend), and OBV is greater than its SMA (indicating positive volume inflow). Short conditions are the opposite.

longCond = inSession and chop < chopThresh and obv > obvSma
shortCond = inSession and chop < chopThresh and obv < obvSma
Enter fullscreen mode Exit fullscreen mode

ATR-Based Exit Strategy: The strategy uses ATR multiplied by a factor to determine stop-loss and take-profit levels, allowing exit points to adapt to current market volatility.

strategy.exit("Exit Long", from_entry="Long", stop=close - atr * atrMult, profit=atr * atrMult)
strategy.exit("Exit Short", from_entry="Short", stop=close + atr * atrMult, profit=atr * atrMult)
Enter fullscreen mode Exit fullscreen mode

Strategy Advantages
Through in-depth code analysis, this strategy demonstrates several significant advantages:

  1. Adaptive to Market Volatility: By using ATR as the exit standard, the strategy can automatically adjust stop-loss and target levels according to current market volatility, avoiding the inadequacy of fixed levels in different volatility environments. This allows the strategy to maintain stable performance in both high and low volatility markets.

  2. Effective Noise Filtering: The application of the Choppiness Index ensures the strategy only trades when clear trends emerge, effectively avoiding sideways consolidating markets and reducing unnecessary losses from false signals.

  3. Volume Confirmation Enhances Reliability: The comparison between OBV and its moving average provides volume-level confirmation, ensuring price movements have sufficient volume support, significantly improving signal reliability.

  4. Flexible Parameter Adjustment: The strategy offers multiple adjustable parameters, including ATR length and multiplier, Choppiness threshold and length, OBV SMA length, etc., allowing traders to optimize according to different market conditions and personal preferences.

  5. Session Time Control: Through the session filter, the strategy can avoid generating signals during low liquidity periods or market closures, effectively reducing overnight gap risk and execution slippage.

  6. Clear and Concise Signals: Compared to using multiple overlapping indicators or complex condition combinations, this strategy's conditions are concise and clear, easy to understand and execute, improving trading decision efficiency and confidence.

Strategy Risks
Despite its many advantages, this strategy still has some potential risks that traders should be aware of:

  1. Period Dependency: The calculations of the Choppiness Index and OBV depend on specific time periods, and different observation periods may lead to drastically different signals. Traders need to adjust parameters according to specific trading instruments and timeframes, otherwise inappropriate signals may be generated.

  2. False Breakout Risk: During market transitions, even if the Choppiness Index is below the threshold, the market may experience false breakouts, leading to erroneous signals. The solution is to add additional confirmation indicators or extend the observation period.

  3. Symmetry of Stop-Loss and Take-Profit: The current strategy uses the same ATR multiplier for setting both stop-loss and take-profit, which may not be suitable for all market environments, especially in markets with varying trend strengths. Consider setting different ATR multipliers for stop-loss and take-profit, or implementing a dynamic take-profit strategy.

  4. Session Setting Limitations: Fixed session settings may cause important market opportunities outside sessions to be missed, especially under the influence of global market events. Traders may need to flexibly adjust trading sessions according to specific market events.

  5. Signal Frequency Issues: Under certain market conditions, signals may be too frequent or too rare, requiring adjustment of the Choppiness threshold or OBV SMA length to balance signal quantity and quality.

Strategy Optimization Directions
Based on code analysis, the following optimization directions can be proposed:

Dynamic ATR Multiplier: Currently, the ATR multiplier is fixed and could be improved to dynamically adjust based on market volatility or trend strength. For example, use a larger take-profit multiplier in stronger trending markets and a larger stop-loss multiplier in more volatile markets. Optimization code could be:

dynamicProfitMult = atrMult * (1 + (100 - chop) / 100)
strategy.exit("Exit Long", from_entry="Long", stop=close - atr * atrMult, profit=atr * dynamicProfitMult)
Enter fullscreen mode Exit fullscreen mode

Introduce Trend Confirmation: Add comparison of short-term and long-term moving averages to provide additional trend confirmation, reducing false signals. This can be implemented with the following code:

shortMA = ta.sma(close, 5)
longMA = ta.sma(close, 20)
trendConfirmation = shortMA > longMA
longCond = inSession and chop < chopThresh and obv > obvSma and trendConfirmation
Enter fullscreen mode Exit fullscreen mode

Add Time Filtering: Based on market characteristics at different times, set different parameters for different periods, such as using stricter conditions during opening and closing hours. This requires adding time filtering logic:

isOpeningHour = (hour >= 9 and hour < 10)
isClosingHour = (hour >= 15 and hour < 16)
adjustedChopThresh = isOpeningHour or isClosingHour ? chopThresh * 0.8 : chopThresh
Enter fullscreen mode Exit fullscreen mode

Partial Position Management: The current strategy uses a fixed position size, which could be improved to adjust position size based on signal strength or market conditions, for example:

signalStrength = (chopThresh - chop) / chopThresh
positionSize = strategy.percent_of_equity * math.min(1, math.max(0.3, signalStrength))
Enter fullscreen mode Exit fullscreen mode

Optimize Exit Strategy: Consider implementing trailing stops or stepped take-profits, allowing the strategy to lock in more profits when trends continue while protecting existing gains:

strategy.exit("Exit Long", from_entry="Long", stop=close - atr * atrMult, trail_points=atr * atrMult * 2, trail_offset=atr * atrMult)
Enter fullscreen mode Exit fullscreen mode

Summary
The Momentum Trend Recognition with Adaptive Volatility ATR Integrated Quantitative Trading Strategy is an elegantly designed short-term trading system, combining the Choppiness Index for trend recognition, OBV for volume confirmation, and ATR for exit management, providing traders with a comprehensive and efficient trading framework. The core advantages of this strategy lie in its adaptability and noise filtering capability, allowing it to maintain relatively stable performance under different market conditions.

However, like all trading strategies, it also faces challenges such as parameter optimization, false signal risk, and market-specific risks. By implementing the suggested optimization directions, such as dynamic ATR multipliers, additional trend confirmation, time filtering, position management, and improved exit strategies, traders can further enhance the robustness and profitability of this strategy.

The key to successfully applying this strategy lies in fully understanding its principles, adjusting parameters according to specific market conditions, and always maintaining appropriate risk management. Through paper trading and continuous optimization, traders can develop this strategy into a powerful tool in their personal trading system.

Strategy source code

/*backtest
start: 2024-05-13 00:00:00
end: 2025-05-11 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"DOGE_USDT"}]
*/

//@version=6
strategy("ChopFlow ATR Scalp Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// === Inputs ===
atrLength     = input.int(14, title="ATR Length", minval=1)
atrMult       = input.float(1.5, title="ATR Multiplier", minval=0.1)
chopLength    = input.int(14, title="Choppiness Length", minval=1)
chopThresh    = input.float(60.0, title="Choppiness Threshold")
obvSmaLength  = input.int(10, title="OBV SMA Length", minval=1)

// === ATR ===
atr = ta.rma(ta.tr(true), atrLength)

// === Choppiness Index ===
tr      = ta.tr(true)
sumTR   = math.sum(tr, chopLength)
range_  = ta.highest(high, chopLength) - ta.lowest(low, chopLength)
chop    = 100 * math.log(sumTR / range_) / math.log(chopLength)

// === On-Balance Volume ===
obv     = ta.cum(math.sign(ta.change(close)) * volume)
obvSma  = ta.sma(obv, obvSmaLength)

// === Entry Conditions (no BB) ===
longCond  = chop < chopThresh and obv > obvSma
shortCond = chop < chopThresh and obv < obvSma

if longCond
    strategy.entry("Long", strategy.long)
if shortCond
    strategy.entry("Short", strategy.short)

// === ATR-Based Exit ===
strategy.exit("Exit Long",  from_entry="Long",  stop=close - atr * atrMult, profit=atr * atrMult)
strategy.exit("Exit Short", from_entry="Short", stop=close + atr * atrMult, profit=atr * atrMult)

// === (Optional) Debug Plots ===
// plot(chop, title="Choppiness", color=color.grey)
// hline(chopThresh, "Chop Threshold", color=color.yellow)
// plot(obv,  title="OBV", color=color.blue)
// plot(obvSma, title="OBV SMA", color=color.orange)
Enter fullscreen mode Exit fullscreen mode

Strategy parameters

Image description

The original address: Momentum Trend Recognition with Adaptive Volatility ATR Integrated Quantitative Trading Strategy

Comments 1 total

  • ru zhang
    ru zhangJun 3, 2025

    This article is insightful and well-structured. The author clearly put a lot of thought into presenting complex ideas in a clear and practical way. I especially appreciated the real-world examples—it really helped me connect the theory to application. Great work!

Add comment