OPEN-SOURCE SCRIPT
MACD Matrix [Quantum Algo]

MACD Matrix [Quantum Algo]
═══════════════════════════════════════════════
🔶 OVERVIEW
MACD Matrix reads the Moving Average Convergence Divergence as a complete momentum system rather than a single line and histogram. It classifies momentum into four quadrants instead of one sign, aligns four timeframes into a live matrix with a scored consensus, detects histogram divergence and draws it on both the oscillator and the price candles, tracks histogram compression before expansion, and paints a momentum river through price so the entire reading lives on the chart — not only in the pane below it.
The result is a MACD you can read from the candles alone: the river's color tells you the quadrant, the aura tells you whether momentum is expanding or fading, gold beacons mark full multi-timeframe alignment, and every signal carries its own historical record on the exact symbol you are trading.
═══════════════════════════════════════════════
🔶 WHAT IS MACD?
The Moving Average Convergence Divergence, created by Gerald Appel, measures momentum as the distance between a fast and a slow exponential moving average. A signal line smooths that distance, and the histogram — introduced by Thomas Aspray — shows the gap between the two. MACD above zero means the fast average leads the slow one (bullish regime); the histogram rising means momentum is accelerating.
═══════════════════════════════════════════════
🔶 WHAT ARE THE FOUR MACD QUADRANTS?
Most traders read MACD as bullish or bearish. It actually has four distinct states, and the difference between them is where the money is:
— Expanding ▲: above zero and the histogram rising — momentum accelerating in an uptrend.
— Fading ▲: above zero and the histogram falling — the uptrend losing thrust, the earliest warning.
— Expanding ▼: below zero and the histogram falling — momentum accelerating in a downtrend.
— Fading ▼: below zero and the histogram rising — the downtrend losing thrust, the earliest turn.
MACD Matrix names the quadrant on every bar, colors the river and the aura by it, and stamps it into every signal's tooltip.
═══════════════════════════════════════════════
🔶 WHY IS THIS ORIGINAL?
1. The quadrant engine. Four momentum phases instead of two, made visible on the price chart through the momentum river and aura, so fading momentum is caught before the sign ever flips.
2. The timeframe matrix. Four configurable timeframes, each read as side-of-zero × expanding-or-fading, with a consensus score. A gold beacon prints on price the moment all four align with expanding momentum — a threshold event, not a vague "trend agreement."
3. Dual-canvas divergence. Histogram divergences are drawn as connectors in the pane AND as dashed twins across the corresponding price pivots on the chart, so the divergence is visible exactly where you trade it.
4. The histogram squeeze. Histogram amplitude is ranked inside its own recent history; when it compresses below a low percentile the momentum is coiled, marked with gold dots, and the expansion out of the coil fires a directional release signal — a compression concept almost never applied to MACD.
5. Signal families with per-symbol records. Zero-line crosses, early signal crosses on the correct side of zero, divergences and squeeze releases are tracked as separate families, each with ten-bar outcome statistics shrunk toward neutral at small samples and a Wilson lower bound — quoted in every tooltip and on the dashboard.
═══════════════════════════════════════════════
🔶 HOW IT WORKS
— MACD, signal and histogram are computed from configurable lengths; the quadrant is derived from the sign of MACD and the direction of the histogram.
— Four higher-timeframe MACD states are requested without lookahead and scored into the matrix.
— Histogram pivots are compared against price pivots to detect regular divergences, drawn on both canvases.
— Histogram amplitude is ranked against its own history for the squeeze; a mature coil that expands fires a release.
— Every signal family feeds its own first-in-first-out outcome samples; statistics are reported with sample counts.
Signals are evaluated on confirmed bars and do not repaint. Higher-timeframe matrix rows finalize when their own bar closes, as with any multi-timeframe reading. All drawings are capped.
═══════════════════════════════════════════════
🔶 HOW TO USE IT
— Trade the quadrant, not the sign: Expanding phases favor continuation entries; Fading phases favor taking profit or tightening risk, and they precede most zero-line crosses.
— Use the matrix as a filter: a 4/4 beacon is the highest-conviction environment; a divided matrix (2/4) warns that timeframes disagree.
— Divergence on the candles: when the dashed price line and the pane connector appear together, you have a momentum-versus-price disagreement located precisely on structure.
— Watch the coil: a long squeeze followed by a release is the setup for expansion; the R family record tells you how reliably releases have followed through here.
— Works on all markets and timeframes; configure the four matrix timeframes to match your trading horizon.
═══════════════════════════════════════════════
🔶 SETTINGS
— MACD: fast, slow and signal lengths.
— Timeframe Matrix: four timeframes.
— Signals & Squeeze: divergence pivot length, squeeze window and percentile, cooldown, signal visibility.
— Statistics: sample cap, minimum samples, shrinkage strength, Wilson z-score.
— Visuals and dashboard: river and aura toggles, river length, full color and position control.
═══════════════════════════════════════════════
🔶 ALERTS
— Matrix Aligned Bullish / Bearish — all four timeframes aligned with expanding momentum.
— Zero-Line Cross — MACD crossed zero.
— Histogram Divergence — a divergence printed.
— Squeeze Release — the histogram expanded out of its coil.
═══════════════════════════════════════════════
🔶 FAQ
Q: Does it repaint?
A: Signals are evaluated on confirmed bars and never change once printed. The higher-timeframe rows of the matrix update while their own bar is open and finalize at its close — this is inherent to any multi-timeframe reading, and no lookahead is used.
Q: How is this different from a standard MACD?
A: A standard MACD shows one line, one signal and one histogram in a pane. This tool adds the quadrant classification, the four-timeframe matrix and beacons, divergence drawn on the price chart itself, the histogram squeeze, the momentum river and aura on price, and per-family statistics.
Q: What does the momentum river represent?
A: A short exponential average of price colored by the current MACD quadrant. Its purpose is purely to carry the momentum reading onto the candles — bright when momentum expands, dimmed when it fades — so you can read momentum without looking away from price.
Q: What do the family percentages mean?
A: The share of past signals in that family after which price had moved favorably ten bars later, on the current symbol and timeframe, shrunk toward fifty percent at small samples. They describe history — they are not predictions.
Q: Which settings should I change first?
A: The four matrix timeframes, so the matrix reflects your own trading horizons. The MACD lengths follow the classic 12, 26, 9 defaults.
═══════════════════════════════════════════════
🔶 CREDITS
The Moving Average Convergence Divergence is by Gerald Appel; the MACD histogram is by Thomas Aspray (1986). The Wilson score interval is by Edwin B. Wilson (1927). The quadrant engine, timeframe matrix and beacon logic, dual-canvas divergence rendering, histogram squeeze, per-symbol statistics and all code in this script are original work — no third-party or open-source script code was reused.
═══════════════════════════════════════════════
🔶 LIMITATIONS
— MACD is a lagging momentum measure; the quadrant engine reduces but cannot eliminate lag.
— Divergences can extend before resolving; the family record exists to quantify this on your chart.
— Statistics describe the current chart's history only; past frequencies never guarantee future outcomes.
═══════════════════════════════════════════════
🔶 DISCLAIMER
This indicator is a research and charting tool provided for educational purposes. It is not financial advice, and nothing it displays is a recommendation to buy or sell any asset. Trading involves substantial risk of loss. Always do your own analysis and manage risk responsibly.
═══════════════════════════════════════════════
🔶 OVERVIEW
MACD Matrix reads the Moving Average Convergence Divergence as a complete momentum system rather than a single line and histogram. It classifies momentum into four quadrants instead of one sign, aligns four timeframes into a live matrix with a scored consensus, detects histogram divergence and draws it on both the oscillator and the price candles, tracks histogram compression before expansion, and paints a momentum river through price so the entire reading lives on the chart — not only in the pane below it.
The result is a MACD you can read from the candles alone: the river's color tells you the quadrant, the aura tells you whether momentum is expanding or fading, gold beacons mark full multi-timeframe alignment, and every signal carries its own historical record on the exact symbol you are trading.
═══════════════════════════════════════════════
🔶 WHAT IS MACD?
The Moving Average Convergence Divergence, created by Gerald Appel, measures momentum as the distance between a fast and a slow exponential moving average. A signal line smooths that distance, and the histogram — introduced by Thomas Aspray — shows the gap between the two. MACD above zero means the fast average leads the slow one (bullish regime); the histogram rising means momentum is accelerating.
═══════════════════════════════════════════════
🔶 WHAT ARE THE FOUR MACD QUADRANTS?
Most traders read MACD as bullish or bearish. It actually has four distinct states, and the difference between them is where the money is:
— Expanding ▲: above zero and the histogram rising — momentum accelerating in an uptrend.
— Fading ▲: above zero and the histogram falling — the uptrend losing thrust, the earliest warning.
— Expanding ▼: below zero and the histogram falling — momentum accelerating in a downtrend.
— Fading ▼: below zero and the histogram rising — the downtrend losing thrust, the earliest turn.
MACD Matrix names the quadrant on every bar, colors the river and the aura by it, and stamps it into every signal's tooltip.
═══════════════════════════════════════════════
🔶 WHY IS THIS ORIGINAL?
1. The quadrant engine. Four momentum phases instead of two, made visible on the price chart through the momentum river and aura, so fading momentum is caught before the sign ever flips.
2. The timeframe matrix. Four configurable timeframes, each read as side-of-zero × expanding-or-fading, with a consensus score. A gold beacon prints on price the moment all four align with expanding momentum — a threshold event, not a vague "trend agreement."
3. Dual-canvas divergence. Histogram divergences are drawn as connectors in the pane AND as dashed twins across the corresponding price pivots on the chart, so the divergence is visible exactly where you trade it.
4. The histogram squeeze. Histogram amplitude is ranked inside its own recent history; when it compresses below a low percentile the momentum is coiled, marked with gold dots, and the expansion out of the coil fires a directional release signal — a compression concept almost never applied to MACD.
5. Signal families with per-symbol records. Zero-line crosses, early signal crosses on the correct side of zero, divergences and squeeze releases are tracked as separate families, each with ten-bar outcome statistics shrunk toward neutral at small samples and a Wilson lower bound — quoted in every tooltip and on the dashboard.
═══════════════════════════════════════════════
🔶 HOW IT WORKS
— MACD, signal and histogram are computed from configurable lengths; the quadrant is derived from the sign of MACD and the direction of the histogram.
— Four higher-timeframe MACD states are requested without lookahead and scored into the matrix.
— Histogram pivots are compared against price pivots to detect regular divergences, drawn on both canvases.
— Histogram amplitude is ranked against its own history for the squeeze; a mature coil that expands fires a release.
— Every signal family feeds its own first-in-first-out outcome samples; statistics are reported with sample counts.
Signals are evaluated on confirmed bars and do not repaint. Higher-timeframe matrix rows finalize when their own bar closes, as with any multi-timeframe reading. All drawings are capped.
═══════════════════════════════════════════════
🔶 HOW TO USE IT
— Trade the quadrant, not the sign: Expanding phases favor continuation entries; Fading phases favor taking profit or tightening risk, and they precede most zero-line crosses.
— Use the matrix as a filter: a 4/4 beacon is the highest-conviction environment; a divided matrix (2/4) warns that timeframes disagree.
— Divergence on the candles: when the dashed price line and the pane connector appear together, you have a momentum-versus-price disagreement located precisely on structure.
— Watch the coil: a long squeeze followed by a release is the setup for expansion; the R family record tells you how reliably releases have followed through here.
— Works on all markets and timeframes; configure the four matrix timeframes to match your trading horizon.
═══════════════════════════════════════════════
🔶 SETTINGS
— MACD: fast, slow and signal lengths.
— Timeframe Matrix: four timeframes.
— Signals & Squeeze: divergence pivot length, squeeze window and percentile, cooldown, signal visibility.
— Statistics: sample cap, minimum samples, shrinkage strength, Wilson z-score.
— Visuals and dashboard: river and aura toggles, river length, full color and position control.
═══════════════════════════════════════════════
🔶 ALERTS
— Matrix Aligned Bullish / Bearish — all four timeframes aligned with expanding momentum.
— Zero-Line Cross — MACD crossed zero.
— Histogram Divergence — a divergence printed.
— Squeeze Release — the histogram expanded out of its coil.
═══════════════════════════════════════════════
🔶 FAQ
Q: Does it repaint?
A: Signals are evaluated on confirmed bars and never change once printed. The higher-timeframe rows of the matrix update while their own bar is open and finalize at its close — this is inherent to any multi-timeframe reading, and no lookahead is used.
Q: How is this different from a standard MACD?
A: A standard MACD shows one line, one signal and one histogram in a pane. This tool adds the quadrant classification, the four-timeframe matrix and beacons, divergence drawn on the price chart itself, the histogram squeeze, the momentum river and aura on price, and per-family statistics.
Q: What does the momentum river represent?
A: A short exponential average of price colored by the current MACD quadrant. Its purpose is purely to carry the momentum reading onto the candles — bright when momentum expands, dimmed when it fades — so you can read momentum without looking away from price.
Q: What do the family percentages mean?
A: The share of past signals in that family after which price had moved favorably ten bars later, on the current symbol and timeframe, shrunk toward fifty percent at small samples. They describe history — they are not predictions.
Q: Which settings should I change first?
A: The four matrix timeframes, so the matrix reflects your own trading horizons. The MACD lengths follow the classic 12, 26, 9 defaults.
═══════════════════════════════════════════════
🔶 CREDITS
The Moving Average Convergence Divergence is by Gerald Appel; the MACD histogram is by Thomas Aspray (1986). The Wilson score interval is by Edwin B. Wilson (1927). The quadrant engine, timeframe matrix and beacon logic, dual-canvas divergence rendering, histogram squeeze, per-symbol statistics and all code in this script are original work — no third-party or open-source script code was reused.
═══════════════════════════════════════════════
🔶 LIMITATIONS
— MACD is a lagging momentum measure; the quadrant engine reduces but cannot eliminate lag.
— Divergences can extend before resolving; the family record exists to quantify this on your chart.
— Statistics describe the current chart's history only; past frequencies never guarantee future outcomes.
═══════════════════════════════════════════════
🔶 DISCLAIMER
This indicator is a research and charting tool provided for educational purposes. It is not financial advice, and nothing it displays is a recommendation to buy or sell any asset. Trading involves substantial risk of loss. Always do your own analysis and manage risk responsibly.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
The institutional Edge: Indicators, Strategies & a Free Academy. quantum-algo.com
All content provided by Quantum Algo is for informational & educational purposes only.
All content provided by Quantum Algo is for informational & educational purposes only.
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
The institutional Edge: Indicators, Strategies & a Free Academy. quantum-algo.com
All content provided by Quantum Algo is for informational & educational purposes only.
All content provided by Quantum Algo is for informational & educational purposes only.
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。