In quantitative trading and technical analysis, structural price mismatches often hint at macro trend exhaustions. Among these patterns, the Double Divergence stands out as an elite structural setup. Unlike a standard divergence—which maps a single historical point to the current price action—a Double Divergence requires consecutive layers of confirmation, dramatically boosting structural accuracy. However, its effectiveness is strictly bound by how well it is calibrated to market volatility and cycle depth.

To extract high-probability setups from NinjaTrader 8, Sierra Chart, TradingView, or cTrader, algorithmic developers and systematic traders must master two critical quantitative inputs: FilterLength and DivergenceLookback. While these variables are illustrated using an ADX-based framework in our technical documentation, the structural mechanics outlined below apply universally across the entire Double Divergence indicator suite, including RSI, CCI, MACD, Stochastic, Money Flow, and DMI variants.


1. The Structural Mechanics of the Core Inputs

To successfully customize the indicator for your specific asset class (e.g., Gold Futures, Equities, Crypto, Forex), it is essential to first separate the mathematical function of each parameter.

FilterLength: The Wave Smoothing Filter

The FilterLength parameter controls the mathematical pre-filtering applied to the underlying oscillator before any divergence logic is processed. Raw trading oscillators are notoriously jagged, generating multiple micro-peaks and valleys inside a single market swing. If left raw, a divergence script will register these micro-movements as minor structural turning points, filling your screen with false triggers.

  • Mathematical Function: Smooths out high-frequency noise from the underlying oscillator line to ensure only macro market structure is evaluated.
  • High Values (e.g., 15): Removes short-term market noise. The underlying engine will only register major market swings, locking on to dominant cyclic turning points.
  • Low Values (e.g., 5): Increases sensitivity, forcing the engine to track ultra-responsive, short-term momentum shifts.

DivergenceLookback: The Horizontal Search Window

Once the smoothed peaks and valleys are established by your filter, DivergenceLookback dictates the horizontal boundaries of the algorithm. It establishes the maximum horizontal distance, measured strictly in bars, that the algorithm can search backward to anchor the divergence lines.

  • Mathematical Function: Limits the structural validity window. A divergence loses technical relevance if the current peak is being compared to an ancient market environment.
  • High Values (e.g., 15): Allows the algorithm to cross-reference multi-day or multi-week market structures, revealing massive macro reversals.
  • Low Values (e.g., 5): Confines the indicator to rapid, back-to-back structural mismatches that occur within tight consolidations.

The Operational Formula: Think of it as a two-stage filter. FilterLength establishes what qualifies as a valid structural pivot point, while DivergenceLookback determines the horizontal boundary limits within which those qualified pivots must sit to trigger a valid double signal.


2. Deep-Dive Comparative Study: Visual Parameters Analyzed

Analyzing cross-sectional behavioral profiles across distinct baseline configurations illustrates exactly how these two variables dictate your chart layout:

Configuration A: Tight & Ultra-Sensitive

  • Settings: Filter Length: 5, Divergence Lookback: 5
  • When both parameters are compressed, the indicator focuses exclusively on hyper-local price structures. With the filter set to 5, the indicator registers minor jiggles in the trend line as complete structural waves. Because the lookback is capped at 5 bars, the engine will only draw divergence lines between peaks or valleys that occur immediately adjacent to each other. This is ideal for fast-paced scalpers targeting micro-reversals inside short-term ranges, though it exposes the trader to localized noise in sweeping trends.

Configuration B: Local Lookback Expansion

  • Settings: Filter Length: 5, Divergence Lookback: 10 to 15
  • As you hold the wave filter tight at 5 but expand the horizontal lookback search window to 10 or 15 bars, a dramatic structural shift occurs. The underlying line remains sensitive and full of micro-peaks, but the indicator is now permitted to search much further left to find matches. This configuration frequently creates a complex web of overlapping divergence lines (as seen in active trends), mapping multi-peak micro-consolidations before an eventual break.

Configuration C: Institutional Macro Smoothing

  • Settings: Filter Length: 15, Divergence Lookback: 15
  • This setting represents the institutional standard for macro trend reversals. By expanding the filter to 15, all micro-fluctuations are completely erased from the internal logic. The indicator visualizes a highly smoothed, clean wave structure. Combined with a lookback of 15, the engine ignores short-term consolidations entirely and focuses exclusively on major structural shift lines. Overlapping lines vanish, leaving behind clean, high-probability macro divergence setups across major swing highs and lows.

3. Cross-Platform Optimization & Selection Matrix

To apply this to your daily workflow, use the optimization matrix below to select parameters aligned with your specific strategy and asset group:

Trading StyleTarget Asset ClassFilterLengthDivergenceLookbackStrategic Focus
Scalping / IntradayIndex Futures (NQ/ES)3 – 54 – 7Quick momentum exhausts in tight bands
Swing TradingEquities & Forex7 – 108 – 12Balanced standard wave identification
Macro / PositionGold Futures (GC) / Commodities12 – 1512 – 20Major multi-week structural turning points

4. Universal Blueprint Across the PatternSmart Suite

While testing these inputs, it is vital to remember that the mathematical logic remains constant regardless of the underlying core oscillator. Whether you run the Double Divergence indicator on ADX, CCI, DMI, MACD, Momentum, MoneyFlow, RSI, RVI, Stochastics, or WilliamsR, the algorithmic engine searches for structural mismatches identically. Adjusting your inputs will yield parallel structural behavior across all versions, allowing you to seamlessly maintain a unified multi-indicator visual system.


  1. The Dynamic Effect of FilterLength:
    • In Image (FilterLength: 5), notice how choppy, jagged, and active the underlying line is. The indicator is forced to label multiple individual minor waves with “H” (Hidden) and “R” (Regular) labels because it registers minor pullbacks as standalone swing segments.
    • In Image (FilterLength: 15), look at how clean the indicator pane becomes. The line is beautifully smoothed out, completely filtering out all the micro-peaks. The local clutter vanishes, and the system focuses strictly on the absolute major trend lines across the macro cycle.
  2. The Dynamic Effect of DivergenceLookback:
    • In Image (Lookback: 5), the lookback window is highly restrictive. The lines linking price pivots to indicator pivots can only anchor to peaks that happened within a tight 5-bar horizontal window.
    • As you scale up to Image (Lookback: 10) and Image (Lookback: 15), the engine keeps the same jagged line (FilterLength: 5), but is given permission to draw much longer horizontal connections to find structural mismatches across older, wider consolidation structures. This leads to the long, sweeping green and orange trend lines stretching far back across the left side of your chart.

Strategic Tuning Recommendation

  • If your charts are too cluttered with lines / text labels: Keep your preferred DivergenceLookback, but increase your FilterLength (e.g., from 5 up to 12 or 15) to force the indicator to ignore minor consolidations.
  • If your charts are missing obvious long-term patterns: Keep your FilterLength steady, but scale up your DivergenceLookback to let the engine search further back in time.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.