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.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.