OPEN-SOURCE SCRIPT
Cumulative Delta Divergence [forexobroker]

Cumulative Delta Divergence detects exhaustion patterns where price extends but cumulative tick-rule signed volume does not follow. The z-scores of cumulative delta and price over the same window are differenced; sustained gaps mark institutional positioning against the current move. Signals fire on EMA cross in the resolution direction.
🔶 ALGORITHM
1. signed_vol = volume * sign(close - close[1]).
2. cum_delta = sum(signed_vol, N).
3. delta_z = cum_delta / (stdev(signed_vol, N) * sqrt(N)).
4. price_z = (close - sma(close, N)) / stdev(close, N).
5. divergence = price_z - delta_z. Bear divergence when divergence >= threshold; bull when <= -threshold.
🔶 SIGNAL LOGIC
- Buy: bull divergence AND close crosses EMA up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: bear divergence AND close crosses EMA down.
- Position-lock state machine.
🔶 INPUTS
- Cumulative Window (default 40)
- Pullback EMA Length (default 8)
- Min Divergence Z (default 0.30)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, EMA toggle, buy / sell colors
🔶 ALERTS
CDD Buy, CDD Sell, CDD Any Signal, CDD Bull Div On, CDD Bear Div On, CDD Strong Bear, CDD Strong Bull, CDD EMA Up, CDD Webhook JSON.
🔶 LIMITATIONS
- Tick-rule signed volume (sign of close - close[1]) is a proxy; true bid / ask delta requires order-book data not available in Pine.
- Forex broker volumes vary; instruments with consistent volume reporting produce cleaner divergences.
- Window N = 40 is the practical balance; shorter windows fire more but flag false divergences.
- Divergence resolution timing varies; some divergences last many bars before resolving.
🔶 ALGORITHM
1. signed_vol = volume * sign(close - close[1]).
2. cum_delta = sum(signed_vol, N).
3. delta_z = cum_delta / (stdev(signed_vol, N) * sqrt(N)).
4. price_z = (close - sma(close, N)) / stdev(close, N).
5. divergence = price_z - delta_z. Bear divergence when divergence >= threshold; bull when <= -threshold.
🔶 SIGNAL LOGIC
- Buy: bull divergence AND close crosses EMA up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: bear divergence AND close crosses EMA down.
- Position-lock state machine.
🔶 INPUTS
- Cumulative Window (default 40)
- Pullback EMA Length (default 8)
- Min Divergence Z (default 0.30)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, EMA toggle, buy / sell colors
🔶 ALERTS
CDD Buy, CDD Sell, CDD Any Signal, CDD Bull Div On, CDD Bear Div On, CDD Strong Bear, CDD Strong Bull, CDD EMA Up, CDD Webhook JSON.
🔶 LIMITATIONS
- Tick-rule signed volume (sign of close - close[1]) is a proxy; true bid / ask delta requires order-book data not available in Pine.
- Forex broker volumes vary; instruments with consistent volume reporting produce cleaner divergences.
- Window N = 40 is the practical balance; shorter windows fire more but flag false divergences.
- Divergence resolution timing varies; some divergences last many bars before resolving.
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.
🔵Gain access to our powerful tools : kestutisbalciunas.com/tradingview/
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
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.
🔵Gain access to our powerful tools : kestutisbalciunas.com/tradingview/
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
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.