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提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。