OPEN-SOURCE SCRIPT
Copula Tail Dependency [forexobroker]

Copula Tail Dependency [forexobroker] estimates the empirical lower- and upper-tail dependence between price returns and volume changes using a rank-based copula. Rather than measuring linear correlation (which collapses to a single number and ignores tail behavior), the indicator measures whether extreme co-occurrences are abnormally frequent. The unique angle is that crossovers of the upper- or lower-tail measure above a threshold mark genuine joint-extreme regimes where return-volume co-movement is strong, while ordinary days leave both measures low.
🔶 ALGORITHM
1. Each bar's one-step log return and volume change are computed.
2. Both series are rank-transformed within the last N (default 50) bars; the rank divided by N produces a uniform marginal U for returns and V for volume changes.
3. The empirical lower-tail dependence is lambda_L = count(U <= u AND V <= u) / count(V <= u) for u equal to the tail fraction (default 0.1).
4. The empirical upper-tail dependence is lambda_U = count(U >= 1-u AND V >= 1-u) / count(V >= 1-u).
5. Both quantities live on [0, 1]; values near 0 indicate independence at the tails, values near 1 indicate strong joint-extreme behavior.
6. A signal threshold (default 0.5) defines the line above which the tail measure is treated as a co-movement regime.
7. Bullish signal: lambda_U crosses above the threshold. Bearish signal: lambda_L crosses above the threshold.
🔶 SIGNAL LOGIC
- Buy: lambda_U crosses above the threshold AND session filter passes AND position is not already long AND cooldown bars elapsed AND barstate.isconfirmed.
- Sell: lambda_L crosses above the threshold AND session filter passes AND position is not already short AND cooldown bars elapsed AND barstate.isconfirmed.
The cross-up trigger filters out sustained-tail regimes that have already been priced in; entries fire only when joint-tail strength is freshly established.
🔶 INPUTS
- Calculation group: Window N (default 50), Tail Fraction u (default 0.1), Signal Threshold (default 0.5).
- Signal Logic group: cooldown bars (default 15).
- Filters group: optional session restriction (default 0000-2400).
- Visual group: dashboard toggle, 3-layer glow toggle, upper-tail and lower-tail colors, dashboard background.
🔶 ALERTS
CTD Buy, CTD Sell, CTD Any Signal, CTD Upper Tail Up, CTD Lower Tail Up, CTD Upper Tail Dn, CTD Lower Tail Dn, CTD Symmetric Tails, CTD Webhook JSON.
🔶 LIMITATIONS
- Volume is required, so on symbols without exchange volume the lower/upper tail estimates degrade to noise.
- The rank transform uses a fixed look-back, so the marginal CDF is local rather than global; very long-trend regimes can suppress tail measures.
- With N = 50 and u = 0.1, the upper and lower tails each contain only 5 reference points; small sample noise is expected.
- The indicator measures co-movement direction, not magnitude; it does not size the move.
- A high lambda_U can persist during slow grinding uptrends and then mean-revert, so re-entries from cool to hot are the cleanest signals.
🔶 ALGORITHM
1. Each bar's one-step log return and volume change are computed.
2. Both series are rank-transformed within the last N (default 50) bars; the rank divided by N produces a uniform marginal U for returns and V for volume changes.
3. The empirical lower-tail dependence is lambda_L = count(U <= u AND V <= u) / count(V <= u) for u equal to the tail fraction (default 0.1).
4. The empirical upper-tail dependence is lambda_U = count(U >= 1-u AND V >= 1-u) / count(V >= 1-u).
5. Both quantities live on [0, 1]; values near 0 indicate independence at the tails, values near 1 indicate strong joint-extreme behavior.
6. A signal threshold (default 0.5) defines the line above which the tail measure is treated as a co-movement regime.
7. Bullish signal: lambda_U crosses above the threshold. Bearish signal: lambda_L crosses above the threshold.
🔶 SIGNAL LOGIC
- Buy: lambda_U crosses above the threshold AND session filter passes AND position is not already long AND cooldown bars elapsed AND barstate.isconfirmed.
- Sell: lambda_L crosses above the threshold AND session filter passes AND position is not already short AND cooldown bars elapsed AND barstate.isconfirmed.
The cross-up trigger filters out sustained-tail regimes that have already been priced in; entries fire only when joint-tail strength is freshly established.
🔶 INPUTS
- Calculation group: Window N (default 50), Tail Fraction u (default 0.1), Signal Threshold (default 0.5).
- Signal Logic group: cooldown bars (default 15).
- Filters group: optional session restriction (default 0000-2400).
- Visual group: dashboard toggle, 3-layer glow toggle, upper-tail and lower-tail colors, dashboard background.
🔶 ALERTS
CTD Buy, CTD Sell, CTD Any Signal, CTD Upper Tail Up, CTD Lower Tail Up, CTD Upper Tail Dn, CTD Lower Tail Dn, CTD Symmetric Tails, CTD Webhook JSON.
🔶 LIMITATIONS
- Volume is required, so on symbols without exchange volume the lower/upper tail estimates degrade to noise.
- The rank transform uses a fixed look-back, so the marginal CDF is local rather than global; very long-trend regimes can suppress tail measures.
- With N = 50 and u = 0.1, the upper and lower tails each contain only 5 reference points; small sample noise is expected.
- The indicator measures co-movement direction, not magnitude; it does not size the move.
- A high lambda_U can persist during slow grinding uptrends and then mean-revert, so re-entries from cool to hot are the cleanest signals.
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 : forexobroker.com/tv
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
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 : forexobroker.com/tv
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
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.