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.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
🔵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.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
🔵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.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.