OPEN-SOURCE SCRIPT
Auto-Lensed MACD + Z-Score v8.2

The AL-MACD represents a departure from static technical analysis. While traditional oscillators use fixed mathematical constants, this indicator treats the market as a living, breathing cycle that requires a dynamic "Lens" to view clearly.
1. The Core Innovation: The Adaptive Lens
Standard MACDs are often "too fast" in volatile markets (causing noise) or "too slow" in trending markets (causing lag).
How it works: The script constantly measures the distance between recent price pivots to determine the Market Tempo.
The Result: It automatically recalculates its own Fast, Slow, and Signal lengths. If the market cycle compresses, the MACD tightens to catch the move; if the cycle expands, the MACD smooths out to avoid fakeouts.
2. Statistical Extremity (Z-Score Integration)
We integrated a price-based Z-Score (Standard Deviation) logic to provide a "Mean Reversion" layer.
Normalization: The Z-Score is normalized to the MACD scale so that the threshold bands breathe with the momentum.
Exhaustion Coloring: The histogram turns Aqua or Magenta when the price is statistically overextended (sigma>2.0 SD). This tells you a move is "out of breath" even before a reversal begins.
3. Signal Intelligence & Noise Reduction
To solve the "dot cluster" problem common in divergence indicators, we implemented a Quiet Build architecture:
ATR Magnitude Filter: Divergences are ignored if the price move between pivots is too small to be significant.
Signal Cooldown: A mandatory "rest period" (default 15 bars) prevents the script from firing repeated signals during a slow grind.
Slope Filter: Ignores signals if the MACD momentum is essentially flat.
4. Visual Interface & Dashboard
The Dashboard: Provides a real-time "Flight Deck" including Lens Speed, Price Z-Score, and current Adaptive Lengths.
Timeframe Recommendations: A dynamic "Rec Pivot" feature that tells the user exactly which structural settings to use based on the current chart interval (15s vs. Daily).
Sniper Alerts: A confluence-based alert system that only triggers when a Divergence meets a Z-Score extremity—the "A+ Setup."
5. Strategy Cheat Sheet
Signal
Market Context
Action
Histogram Color Shift
Z-Score sigma> 2.0
Alert: Market is overextended.
"R" Triangle + Magenta/Aqua
Divergence at Extremity
Entry: High-conviction mean reversion (The Sniper).
Rising Lens Speed
Cycle lengths are increasing
Wait: Market is entering a slow, trending grind.
Falling Lens Speed
Cycle lengths are decreasing
Prep: Volatility is coiling; expect a fast move.
1. The Core Innovation: The Adaptive Lens
Standard MACDs are often "too fast" in volatile markets (causing noise) or "too slow" in trending markets (causing lag).
How it works: The script constantly measures the distance between recent price pivots to determine the Market Tempo.
The Result: It automatically recalculates its own Fast, Slow, and Signal lengths. If the market cycle compresses, the MACD tightens to catch the move; if the cycle expands, the MACD smooths out to avoid fakeouts.
2. Statistical Extremity (Z-Score Integration)
We integrated a price-based Z-Score (Standard Deviation) logic to provide a "Mean Reversion" layer.
Normalization: The Z-Score is normalized to the MACD scale so that the threshold bands breathe with the momentum.
Exhaustion Coloring: The histogram turns Aqua or Magenta when the price is statistically overextended (sigma>2.0 SD). This tells you a move is "out of breath" even before a reversal begins.
3. Signal Intelligence & Noise Reduction
To solve the "dot cluster" problem common in divergence indicators, we implemented a Quiet Build architecture:
ATR Magnitude Filter: Divergences are ignored if the price move between pivots is too small to be significant.
Signal Cooldown: A mandatory "rest period" (default 15 bars) prevents the script from firing repeated signals during a slow grind.
Slope Filter: Ignores signals if the MACD momentum is essentially flat.
4. Visual Interface & Dashboard
The Dashboard: Provides a real-time "Flight Deck" including Lens Speed, Price Z-Score, and current Adaptive Lengths.
Timeframe Recommendations: A dynamic "Rec Pivot" feature that tells the user exactly which structural settings to use based on the current chart interval (15s vs. Daily).
Sniper Alerts: A confluence-based alert system that only triggers when a Divergence meets a Z-Score extremity—the "A+ Setup."
5. Strategy Cheat Sheet
Signal
Market Context
Action
Histogram Color Shift
Z-Score sigma> 2.0
Alert: Market is overextended.
"R" Triangle + Magenta/Aqua
Divergence at Extremity
Entry: High-conviction mean reversion (The Sniper).
Rising Lens Speed
Cycle lengths are increasing
Wait: Market is entering a slow, trending grind.
Falling Lens Speed
Cycle lengths are decreasing
Prep: Volatility is coiling; expect a fast move.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.