OPEN-SOURCE SCRIPT
CTZ Accumulation/Distribution

**CTZ Accumulation/Distribution**
A volume-based indicator that tracks whether money is flowing into or out of an asset by measuring where price closes within each bar's range, weighted by volume.
**How it works**
Each bar, a Money Flow Multiplier is calculated from the close's position between the high and low (–1 to +1). This is multiplied by volume to produce Money Flow Volume, which is added to a running cumulative total — the A/D line. Closes near the high on heavy volume push the line up (accumulation); closes near the low on heavy volume push it down (distribution).
**Features**
- **A/D Line with trend colouring** — teal when above the signal EMA, red when below, giving an at-a-glance read on money flow direction
- **Signal EMA (default 21)** — smooths the A/D line and acts as a trend filter; crosses can be used as early momentum shifts
- **Automatic divergence detection** — pivot-based logic flags bullish divergence (price makes a lower low while A/D makes a higher low = hidden accumulation) and bearish divergence (price makes a higher high while A/D makes a lower high = distribution into strength)
- **Built-in alerts** — divergence signals and signal-line crosses in both directions
**How to use it**
Confirmation: when price and the A/D line rise together, the uptrend is supported by real buying pressure. When they fall together, the downtrend is genuine.
Divergence: when price and the A/D line disagree, treat it as an early warning. Bull labels suggest smart money is accumulating into weakness; Bear labels suggest distribution into rising prices. These work best on higher timeframes and near key levels — not as standalone entries.
**Settings**
Signal EMA length, pivot lookback (sensitivity of divergence detection), and max bars between pivots (how far apart two pivots can be and still count as a divergence) are all adjustable.
**Limitations**
The A/D line ignores gaps between bars — an asset gapping up overnight registers nothing if it then closes mid-range. Pivot-confirmed divergence labels print a few bars after the pivot by design. Best used alongside momentum tools (RSI, MFI) rather than in isolation.
A volume-based indicator that tracks whether money is flowing into or out of an asset by measuring where price closes within each bar's range, weighted by volume.
**How it works**
Each bar, a Money Flow Multiplier is calculated from the close's position between the high and low (–1 to +1). This is multiplied by volume to produce Money Flow Volume, which is added to a running cumulative total — the A/D line. Closes near the high on heavy volume push the line up (accumulation); closes near the low on heavy volume push it down (distribution).
**Features**
- **A/D Line with trend colouring** — teal when above the signal EMA, red when below, giving an at-a-glance read on money flow direction
- **Signal EMA (default 21)** — smooths the A/D line and acts as a trend filter; crosses can be used as early momentum shifts
- **Automatic divergence detection** — pivot-based logic flags bullish divergence (price makes a lower low while A/D makes a higher low = hidden accumulation) and bearish divergence (price makes a higher high while A/D makes a lower high = distribution into strength)
- **Built-in alerts** — divergence signals and signal-line crosses in both directions
**How to use it**
Confirmation: when price and the A/D line rise together, the uptrend is supported by real buying pressure. When they fall together, the downtrend is genuine.
Divergence: when price and the A/D line disagree, treat it as an early warning. Bull labels suggest smart money is accumulating into weakness; Bear labels suggest distribution into rising prices. These work best on higher timeframes and near key levels — not as standalone entries.
**Settings**
Signal EMA length, pivot lookback (sensitivity of divergence detection), and max bars between pivots (how far apart two pivots can be and still count as a divergence) are all adjustable.
**Limitations**
The A/D line ignores gaps between bars — an asset gapping up overnight registers nothing if it then closes mid-range. Pivot-confirmed divergence labels print a few bars after the pivot by design. Best used alongside momentum tools (RSI, MFI) rather than in isolation.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.