OPEN-SOURCE SCRIPT
Adaptive MACD Regime, Volatility Bands & Conviction

# Adaptive MACD — Regime, Volatility Bands & Conviction
## What this is
This is a single, self-contained momentum framework built around **one normalized MACD core**. Instead of plotting a raw MACD and leaving you to judge it, the script surrounds that core with the context a momentum reading needs to be usable: a market-regime filter, an adaptive length stage, a multi-timeframe agreement check, a volatility band, and a conviction score that combines them into one number. It runs on **any symbol and any timeframe** — the price source and every optional reference feed are selectable in Settings.
It is a study/indicator (not a strategy). It does not place orders and does not claim any performance.
---
## Why these components are combined (mashup rationale)
A plain MACD only answers "is momentum up or down right now." On its own it has two well-known weaknesses: it whipsaws during sideways markets, and its fixed 12/26/9 lengths are arbitrary for any given symbol or timeframe. Each module below exists to fix a specific one of those weaknesses, and they are deliberately chained so the output of one informs the next:
1. **Normalized MACD core (L1)** — the MACD histogram is converted to a rolling **z-score**, so a reading of "+2" means the same thing on a low-priced FX pair, a high-priced index, or a 1-minute vs daily chart. Raw MACD values are not comparable across instruments; the z-score is. This is what makes the rest of the framework symbol-agnostic.
2. **Regime filter (L2)** — efficiency ratio + ADX + a volatility-clustering measure classify the market as **Trend / Range / Volatile**. This is used to decide whether a momentum signal should be trusted: MACD crosses are reliable in trends and noisy in ranges, so the regime gates and reweights the core signal rather than treating every cross equally.
3. **Adaptive length stage (L3)** — a dominant-cycle estimate (Ehlers homodyne) retunes the fast/slow/signal lengths toward the market's measured rhythm, instead of a static 12/26/9. You can switch this to a volatility-driven mode or fall back to fixed lengths. This directly addresses the "arbitrary lengths" weakness.
4. **Multi-timeframe confluence (MTF)** — the same MACD logic is evaluated on four higher timeframes, confirmed on bar close so it does not repaint. A single-timeframe cross is weak; agreement across timeframes is the filter.
5. **Volatility band + fade (L4)** — a volume-weighted standard-deviation band around price flags stretched conditions and band-rejection ("fade") setups, used as a mean-reversion counterweight to the trend logic.
6. **Conviction + vetoes (CON)** — all of the above are blended into a single **0–100 conviction score** with hard vetoes (e.g. counter-regime, timeframe disagreement, volatility spike). This is the part that turns several separate readings into one decision so you are not eyeballing five panels.
7. **Risk framework (RISK)** — once there is a signal, it derives an ATR stop, R-multiple targets, and a position-size suggestion from your account equity and risk %. This is shown as thin Entry / Stop / TP1 / TP2 lines on price.
In short: **L1 makes momentum comparable, L2 decides if it can be trusted, L3 tunes it, MTF confirms it, L4 adds a reversion check, CON scores it, and RISK frames it.** None of the layers is decorative — remove any one and the others lose context.
---
## How to use it
1. Add it to any chart and timeframe. It plots in its own lower pane; the trade levels and dashboard overlay on price.
2. Read the **dashboard header**: it shows the current action (BUY / SELL / HOLD / WAIT / FLAT) and the entry/stop.
3. Check **VERDICT + conviction**: a higher score with no active vetoes is a stronger context. Vetoes are listed explicitly so you can see *why* something is blocked.
4. Use **REGIME** to set expectations — trend-following signals make more sense in a Trend regime; the Stretch/Fade rows matter more in Range.
5. The **Entry / Stop / TP1 / TP2 lines** on price show the framework's risk levels for the current signal only; previous trade lines are removed automatically.
6. Optional feeds (reference symbol, volatility index, open interest, cross-asset) are **blank by default** — add your own symbols if you want those confluence inputs, or leave them off. The script degrades gracefully and tells you in the FEEDS row which are live.
---
## Settings worth knowing
- **Price source** — the series the whole engine runs on. Defaults to close; works on any market.
- **Optional reference feeds** — all blank by default and entirely optional, so the script is not tied to any one market or exchange. Enter symbols relevant to your instrument if you want them.
- **Adaptive length driver** — Homodyne (cycle-adaptive), Volatility, or Fixed.
- **Risk & sizing** — account equity, risk %, ATR stop multiple, and value-per-move; the size output is a suggestion only.
- **Dashboard theme** — Auto/Dark/Light; Auto flips colors to stay readable on white or black backgrounds.
- **Name / symbol / timeframe label** — kept on by default so the chart always identifies what is plotted.
---
## What makes it original
It is not a wrapper around a built-in MACD. The core is rebuilt to accept a *series* length (so it can be retuned every bar), normalized to a cross-asset z-score, gated by an explicitly classified regime, and merged with multi-timeframe state into a single weighted conviction score with named vetoes. The volatility-band fade logic and the dominant-cycle length adaptation are integrated into that same score rather than shown as separate, disconnected studies.
---
## Notes and limitations
- Confirm-on-close is on by default to avoid repainting; intrabar values can still update until the bar closes.
- The optional "Call/Put strike" row is a convenience hint derived from price and your strike interval only — **no options-chain data is read and no option P&L is implied.**
- Higher-timeframe and reference-feed requests depend on your data subscription; if a feed is unavailable the script disables the dependent input and continues.
---
## Disclaimer
This script is provided for educational and informational purposes only. It is a technical study, not investment, financial, or trading advice, and not a solicitation to buy or sell any instrument. It does not guarantee any result. Markets involve risk, including loss of capital. Indicator signals, levels, and the position-size suggestion are illustrative and must not be relied on as the basis for any trade. Always do your own research and consider consulting a licensed financial professional before trading. The author accepts no liability for any loss arising from use of this script. Past behavior of any indicator is not indicative of future results.
## What this is
This is a single, self-contained momentum framework built around **one normalized MACD core**. Instead of plotting a raw MACD and leaving you to judge it, the script surrounds that core with the context a momentum reading needs to be usable: a market-regime filter, an adaptive length stage, a multi-timeframe agreement check, a volatility band, and a conviction score that combines them into one number. It runs on **any symbol and any timeframe** — the price source and every optional reference feed are selectable in Settings.
It is a study/indicator (not a strategy). It does not place orders and does not claim any performance.
---
## Why these components are combined (mashup rationale)
A plain MACD only answers "is momentum up or down right now." On its own it has two well-known weaknesses: it whipsaws during sideways markets, and its fixed 12/26/9 lengths are arbitrary for any given symbol or timeframe. Each module below exists to fix a specific one of those weaknesses, and they are deliberately chained so the output of one informs the next:
1. **Normalized MACD core (L1)** — the MACD histogram is converted to a rolling **z-score**, so a reading of "+2" means the same thing on a low-priced FX pair, a high-priced index, or a 1-minute vs daily chart. Raw MACD values are not comparable across instruments; the z-score is. This is what makes the rest of the framework symbol-agnostic.
2. **Regime filter (L2)** — efficiency ratio + ADX + a volatility-clustering measure classify the market as **Trend / Range / Volatile**. This is used to decide whether a momentum signal should be trusted: MACD crosses are reliable in trends and noisy in ranges, so the regime gates and reweights the core signal rather than treating every cross equally.
3. **Adaptive length stage (L3)** — a dominant-cycle estimate (Ehlers homodyne) retunes the fast/slow/signal lengths toward the market's measured rhythm, instead of a static 12/26/9. You can switch this to a volatility-driven mode or fall back to fixed lengths. This directly addresses the "arbitrary lengths" weakness.
4. **Multi-timeframe confluence (MTF)** — the same MACD logic is evaluated on four higher timeframes, confirmed on bar close so it does not repaint. A single-timeframe cross is weak; agreement across timeframes is the filter.
5. **Volatility band + fade (L4)** — a volume-weighted standard-deviation band around price flags stretched conditions and band-rejection ("fade") setups, used as a mean-reversion counterweight to the trend logic.
6. **Conviction + vetoes (CON)** — all of the above are blended into a single **0–100 conviction score** with hard vetoes (e.g. counter-regime, timeframe disagreement, volatility spike). This is the part that turns several separate readings into one decision so you are not eyeballing five panels.
7. **Risk framework (RISK)** — once there is a signal, it derives an ATR stop, R-multiple targets, and a position-size suggestion from your account equity and risk %. This is shown as thin Entry / Stop / TP1 / TP2 lines on price.
In short: **L1 makes momentum comparable, L2 decides if it can be trusted, L3 tunes it, MTF confirms it, L4 adds a reversion check, CON scores it, and RISK frames it.** None of the layers is decorative — remove any one and the others lose context.
---
## How to use it
1. Add it to any chart and timeframe. It plots in its own lower pane; the trade levels and dashboard overlay on price.
2. Read the **dashboard header**: it shows the current action (BUY / SELL / HOLD / WAIT / FLAT) and the entry/stop.
3. Check **VERDICT + conviction**: a higher score with no active vetoes is a stronger context. Vetoes are listed explicitly so you can see *why* something is blocked.
4. Use **REGIME** to set expectations — trend-following signals make more sense in a Trend regime; the Stretch/Fade rows matter more in Range.
5. The **Entry / Stop / TP1 / TP2 lines** on price show the framework's risk levels for the current signal only; previous trade lines are removed automatically.
6. Optional feeds (reference symbol, volatility index, open interest, cross-asset) are **blank by default** — add your own symbols if you want those confluence inputs, or leave them off. The script degrades gracefully and tells you in the FEEDS row which are live.
---
## Settings worth knowing
- **Price source** — the series the whole engine runs on. Defaults to close; works on any market.
- **Optional reference feeds** — all blank by default and entirely optional, so the script is not tied to any one market or exchange. Enter symbols relevant to your instrument if you want them.
- **Adaptive length driver** — Homodyne (cycle-adaptive), Volatility, or Fixed.
- **Risk & sizing** — account equity, risk %, ATR stop multiple, and value-per-move; the size output is a suggestion only.
- **Dashboard theme** — Auto/Dark/Light; Auto flips colors to stay readable on white or black backgrounds.
- **Name / symbol / timeframe label** — kept on by default so the chart always identifies what is plotted.
---
## What makes it original
It is not a wrapper around a built-in MACD. The core is rebuilt to accept a *series* length (so it can be retuned every bar), normalized to a cross-asset z-score, gated by an explicitly classified regime, and merged with multi-timeframe state into a single weighted conviction score with named vetoes. The volatility-band fade logic and the dominant-cycle length adaptation are integrated into that same score rather than shown as separate, disconnected studies.
---
## Notes and limitations
- Confirm-on-close is on by default to avoid repainting; intrabar values can still update until the bar closes.
- The optional "Call/Put strike" row is a convenience hint derived from price and your strike interval only — **no options-chain data is read and no option P&L is implied.**
- Higher-timeframe and reference-feed requests depend on your data subscription; if a feed is unavailable the script disables the dependent input and continues.
---
## Disclaimer
This script is provided for educational and informational purposes only. It is a technical study, not investment, financial, or trading advice, and not a solicitation to buy or sell any instrument. It does not guarantee any result. Markets involve risk, including loss of capital. Indicator signals, levels, and the position-size suggestion are illustrative and must not be relied on as the basis for any trade. Always do your own research and consider consulting a licensed financial professional before trading. The author accepts no liability for any loss arising from use of this script. Past behavior of any indicator is not indicative of future results.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.