Adaptive Momentum Fusion [WillyAlgoTrader]📡 Adaptive Momentum Fusion is a separate-pane oscillator that replaces the fixed EMAs inside a standard MACD with selectable adaptive moving averages — six different adaptation engines that each respond to a different market dimension (efficiency, volatility, fractal structure, momentum, volume, or a weighted composite of all five). The oscillator line and signal line are then processed through Jurik-style smoothing to reduce jitter without adding lag. The result is a MACD-like oscillator where the core moving averages automatically adjust their speed to current market conditions, producing cleaner crossovers, more meaningful histogram readings, and built-in divergence detection.
A standard MACD uses fixed-length EMAs (typically 12/26/9). This means the same smoothing is applied whether the market is trending strongly, ranging sideways, experiencing a volatility spike, or consolidating. The result: late crossovers in trends, whipsaws in ranges, and false divergences during choppy periods.
This indicator solves the problem at the source — the moving averages themselves. Instead of fixed EMAs, each adaptation engine dynamically adjusts the smoothing constant (alpha) on every bar based on a real-time market measurement. In a strong trend, the Efficiency engine detects high directional efficiency and increases alpha → faster MA → earlier crossover. In a range, efficiency drops and alpha decreases → slower MA → fewer whipsaws. Each engine uses a different measurement to achieve this adaptation, and the user selects which dimension matters most for their market.
🧩 WHY THESE COMPONENTS WORK TOGETHER
A MACD with adaptive MAs alone would still produce a noisy signal line (the EMA of the oscillator). Adding adaptation to the base MAs but keeping a fixed EMA for the signal line creates a mismatch: the oscillator adapts but the signal doesn't, causing crossover lag to reappear at the signal level.
This indicator addresses the full signal chain:
Adaptive fast MA → Adaptive slow MA → Oscillator (MACD or PPO) → Jurik-smoothed signal line → 4-state histogram → Divergence scanner
The adaptive MAs eliminate the fixed-speed problem at the source. The MACD/PPO dual mode lets you choose between absolute (price-scaled) and percentage (normalized) output. The Jurik smoother replaces the standard signal EMA with a 3-stage filter that reduces jitter while preserving crossover timing — critical because adaptive oscillators produce more variable readings than fixed ones. The 4-state histogram (accelerating/decelerating × bullish/bearish) quantifies momentum acceleration, not just direction. And the divergence scanner works on the adaptive oscillator itself, which produces more reliable pivots than a fixed MACD because the adaptive MAs have already filtered out noise-driven fluctuations.
Removing the adaptive engines returns you to a standard MACD. Removing the Jurik smoother reintroduces signal line jitter that the adaptive engines amplify. Removing the histogram states loses momentum acceleration information. The full pipeline produces cleaner signals than any subset.
🔍 WHAT MAKES IT ORIGINAL
1️⃣ Six selectable adaptation engines.
Each engine computes a dynamic smoothing constant (alpha) that controls how fast the moving average reacts. All engines feed into the same adaptive EMA core: result = alpha × source + (1 − alpha) × result . The difference is how alpha is calculated:
Efficiency (Kaufman AMA):
Computes the Efficiency Ratio: ER = |price − price | / sum(|price − price |, N). ER ranges from 0 (pure chop — price moves a lot bar-to-bar but goes nowhere net) to 1 (pure trend — every bar moves in the same direction). The smoothing constant: sc = (ER × (fastSc − slowSc) + slowSc)², where fastSc = 2/3, slowSc = 2/31. This is the classic Kaufman Adaptive Moving Average approach. Best all-around engine.
Volatility (ATR-based):
Computes volRatio = ATR(len) / SMA(ATR, len×2). When current volatility exceeds its average (ratio > 1), alpha increases → MA speeds up to track the expanding price action. When volatility contracts (ratio < 1), alpha decreases → MA slows down to avoid noise. Alpha = baseAlpha × volRatio, clamped to . Best for instruments with distinct volatility regimes (crypto, commodities).
Fractal (Hurst-inspired):
Estimates the fractal dimension of the price series using rescaled range analysis: the full-range is compared to the sum of two half-ranges. fracDim = 1 + log(sumHalf) / log(2 × rangeFull). A fractal dimension near 1.0 indicates trending behavior (smooth), near 2.0 indicates mean-reverting (rough). Alpha = exp(−4.6 × (fracDim − 1)), which maps: fracDim ≈ 1.0 → alpha ≈ 1.0 (fast, trending), fracDim ≈ 2.0 → alpha ≈ 0.01 (slow, ranging). Best for detecting regime changes between trending and mean-reverting markets.
Momentum (ROC-based):
Computes the Rate of Change normalized against its recent maximum: norm = |ROC| / highest(|ROC|, len×2). When momentum is strong relative to recent history, alpha increases. Alpha = baseAlpha + norm × (1 − baseAlpha) × 0.5. This makes the MA react faster during breakouts and momentum surges while staying smooth during low-momentum drift. Best for breakout-oriented strategies.
Volume:
Computes volRatio = volume / SMA(volume, len). When volume exceeds its average (institutional participation), the MA speeds up. Alpha = baseAlpha × √(volRatio). The square root prevents extreme volume spikes from making the MA too reactive. Auto-disabled on instruments without volume data (forex) — falls back to baseAlpha. Best for stocks and crypto where volume confirms moves.
Composite (weighted blend):
Runs all five engines simultaneously and blends the results: with volume = 30% Efficiency + 20% Volatility + 20% Fractal + 15% Momentum + 15% Volume. Without volume = 35% Efficiency + 25% Volatility + 25% Fractal + 15% Momentum. This produces the most robust adaptation but is slightly slower because it averages five different smoothing perspectives. Best for users who don't want to choose a single engine.
2️⃣ Jurik-style signal line smoothing.
The standard MACD signal line is a simple EMA of the oscillator. This indicator replaces it with a 3-stage Jurik-inspired filter:
beta = 0.45 × (len − 1) / (0.45 × (len − 1) + 2)
alphaJ = beta³
e0 = (1 − alphaJ) × source + alphaJ × e0
e1 = (source − e0) × (1 − beta) + beta × e1
e2 = (e0 + phase × e1 − e2 ) × (1 − alphaJ)² + alphaJ² × e2
The three stages progressively remove jitter while maintaining phase alignment. The phase parameter (Jitter Reduction, default 0.7) controls how much additional smoothing is applied: 0.0 = minimal smoothing (fast but noisy), 1.0 = maximum smoothing (smooth but slightly more lag). This is particularly important for adaptive oscillators because the variable-speed MAs produce a more erratic oscillator line than fixed EMAs — the Jurik filter absorbs this variability at the signal level.
3️⃣ MACD/PPO dual output mode.
— MACD mode : oscillator = fastMA − slowMA (absolute difference, price-scaled). Readings scale with instrument price — useful for single-instrument analysis.
— PPO mode : oscillator = (fastMA − slowMA) / slowMA × 100 (percentage difference, normalized). Readings are comparable across instruments and time — useful for scanning, multi-market analysis, or consistent threshold settings.
4️⃣ 4-state momentum histogram.
The histogram (oscillator − signal) is classified into four states based on value and direction of change:
— 🟢 Accelerating bullish : histogram > 0 AND rising (momentum strengthening)
— 🟢 Decelerating bullish : histogram > 0 AND falling (momentum fading, potential reversal ahead)
— 🔴 Accelerating bearish : histogram < 0 AND falling (selling pressure increasing)
— 🔴 Decelerating bearish : histogram < 0 AND rising (selling pressure easing, potential bounce)
Each state has a distinct color intensity: accelerating = fully saturated, decelerating = faded. This provides immediate visual recognition of whether momentum is building or exhausting — the most actionable information from a histogram.
5️⃣ Divergence detection with adaptive oscillator.
The indicator scans for regular divergences between price and the adaptive oscillator:
— Regular Bullish Divergence : price makes a lower low, but the oscillator makes a higher low → selling pressure is weakening despite lower prices → potential reversal up
— Regular Bearish Divergence : price makes a higher high, but the oscillator makes a lower high → buying pressure is weakening despite higher prices → potential reversal down
Pivots are detected using a custom function with configurable lookback (default 30 bars) and a fixed right-bar confirmation of 5 bars. Divergences are labeled on the oscillator pane and optionally drawn as connecting lines. The divergence state persists in the dashboard for 20 bars after detection, then decays.
Divergences detected on the adaptive oscillator are more reliable than on a standard MACD because the adaptive MAs have already filtered regime-inappropriate noise — the pivots in the oscillator correspond to genuine momentum shifts, not noise-driven wiggles.
6️⃣ Zero-line cross signals.
When enabled, the indicator marks when the oscillator crosses the zero line — which corresponds to the fast adaptive MA crossing the slow adaptive MA. In MACD terms, this is the equivalent of the "MACD crossing zero." Because the MAs are adaptive, these crossovers occur at more structurally meaningful points than with fixed EMAs.
7️⃣ Signal strength scoring (0–100).
Each bar's histogram absolute value is normalized against its recent maximum over 50 bars: strength = |histogram| / highest(|histogram|, 50) × 100. This provides a relative measure: 100 = histogram is at its strongest in the last 50 bars, 0 = no momentum. Classified as Strong (≥ 70), Medium (≥ 40), Weak (< 40). Displayed in the dashboard.
⚙️ HOW IT WORKS — CALCULATION FLOW
Step 1 — Engine selection: The selected adaptation engine computes a dynamic alpha value on each bar based on its specific market measurement (efficiency ratio, ATR ratio, fractal dimension, ROC normalization, volume ratio, or composite blend).
Step 2 — Adaptive MA calculation: The fast MA and slow MA are each computed using the adaptive EMA formula: result = alpha × source + (1 − alpha) × result . The same engine is used for both, with different length parameters (fast = default 8, slow = default 21).
Step 3 — Oscillator: MACD mode: osc = fastMA − slowMA. PPO mode: osc = (fastMA − slowMA) / slowMA × 100.
Step 4 — Signal line: The oscillator is passed through the Jurik 3-stage filter with the configured signal length (default 7) and jitter reduction factor (default 0.7).
Step 5 — Histogram: hist = oscillator − signal. Classified into 4 states (accelerating/decelerating × bullish/bearish) based on sign and direction of change.
Step 6 — Divergence scan: Custom pivot detection identifies local highs and lows in both the oscillator and price. When a new pivot is found, it's compared to the previous pivot to check for divergence conditions (price lower low + osc higher low, or price higher high + osc lower high).
Step 7 — Signals: Crossovers (oscillator crossing signal line) and zero-line crosses are detected. All signals require barstate.isconfirmed + warmup check.
📖 HOW TO USE
🎯 Quick start:
1. Add the indicator — the adaptive oscillator appears in a separate pane
2. Select an adaptation engine matching your market (Efficiency for general use)
3. Green line above red = bullish momentum, below = bearish
4. Histogram bars show momentum acceleration (bright) vs deceleration (faded)
5. Divergence labels mark potential reversals
👁️ Reading the pane:
— 🟢 Green oscillator line above signal line = bullish momentum
— 🔴 Red oscillator line below signal line = bearish momentum
— 🟢 Bright green histogram = accelerating bullish momentum
— 🟢 Faded green histogram = decelerating bullish (momentum fading)
— 🔴 Bright red histogram = accelerating bearish momentum
— 🔴 Faded red histogram = decelerating bearish (selling easing)
— ▲ label = buy crossover signal (oscillator crosses above signal)
— ▼ label = sell crossover signal
— ● dot on zero line = zero-line cross
— "Bull Div" / "Bear Div" labels = detected divergences
🔧 Engine selection guide:
— Efficiency : best default for most markets — adapts to trending vs ranging
— Volatility : best for instruments with clear vol regimes (crypto, commodities)
— Fractal : best for detecting regime shifts (trending ↔ mean-reverting)
— Momentum : best for breakout strategies — speeds up on strong moves
— Volume : best for stocks/crypto where volume confirms participation
— Composite : most robust — blends all dimensions, good when unsure
🔧 Tuning guide:
— Too many whipsaws: increase Slow Length, increase Signal Length, increase Jitter Reduction
— Signals too late: decrease Fast/Slow Length, decrease Signal Length, decrease Jitter Reduction
— Histogram too noisy: increase Jitter Reduction toward 0.8–1.0
— Divergences too frequent: increase Divergence Lookback (40–60)
— Cross-market comparison: switch to PPO mode for normalized output
⚙️ KEY SETTINGS REFERENCE
⚙️ Main:
— Adaptation Engine (default Efficiency): Efficiency / Volatility / Fractal / Momentum / Volume / Composite
— Fast Length (default 8): fast adaptive MA period
— Slow Length (default 21): slow adaptive MA period
— Signal Length (default 7): Jurik signal smoothing period
— Output Mode (default MACD): MACD (absolute) or PPO (percentage)
🔍 Filters:
— Detect Divergences (default On): scan for regular divergences
— Divergence Lookback (default 30): pivot search depth
— Zero Line Cross Signals (default On): mark zero crossings
🔧 Advanced:
— Jitter Reduction (default 0.7): Jurik phase parameter (0.0–1.0)
— Auto / Dark / Light theme
📊 Dashboard
— Trend: oscillator vs signal line direction (Bullish / Bearish / Neutral)
— Signal: last crossover (BUY / SELL / Wait)
— Strength: histogram normalized to 50-bar max (Strong / Medium / Weak with %)
— Momentum: 4-state acceleration (Accel ▲ / Decel ▽ / Accel ▼ / Decel △)
— Divergence: current divergence state (Bull Div / Bear Div / None)
— Engine / TF: selected engine and timeframe
— Version
🔔 Alerts
— 🟢 BUY / 🔴 SELL — oscillator-signal crossover (ticker, price, timeframe, engine)
— 🟡 ZERO BULL CROSS / ZERO BEAR CROSS — zero-line crossing
— 🔵 BULL DIVERGENCE / BEAR DIVERGENCE — detected divergence
All support plain text and JSON webhook format. Bar-close confirmed.
⚠️ IMPORTANT NOTES
— 🚫 No repainting. All signals and divergences require barstate.isconfirmed. A warmup period (2× slow length, minimum 50 bars) prevents signals during insufficient data. The adaptive MAs are deterministic — once a bar closes, the MA value for that bar never changes.
— 📐 This is a separate-pane oscillator, not an overlay. It displays in its own pane below the chart. The oscillator values are momentum readings, not price levels. Use it alongside your chart for confluence, not as a standalone trading system.
— ⚖️ The six engines produce different signals on the same data . Efficiency and Composite tend to produce the most similar results. Fractal can diverge significantly during regime transitions. Volume engine auto-falls back to base alpha on instruments without volume data.
— 📊 Signal strength is relative to recent 50 bars , not absolute. A "Strong" reading during a low-volatility week may be weaker in absolute terms than a "Weak" reading during a high-volatility week.
— 🔄 Divergences use a 5-bar right confirmation — they appear 5 bars after the actual pivot. This delay is inherent to pivot detection and cannot be eliminated without introducing false positives.
— 📏 PPO mode normalizes the output as a percentage, making threshold settings (e.g., "divergence when oscillator > 2") comparable across instruments. MACD mode values scale with price — a reading of 5.0 on a $100 stock is different from 5.0 on a $50,000 BTC chart.
— 🛠️ This is a momentum analysis tool , not an automated trading bot. It measures and visualizes adaptive momentum — trade decisions remain yours.
— 🌐 Works on all markets and timeframes. Volume engine auto-adapts to available data.
Pine Script® göstergesi






















