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.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
🔵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.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
🔵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.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.