OPEN-SOURCE SCRIPT
CVD Divergence

CVD Divergence highlights when price and Cumulative Volume Delta (CVD) disagree — a classic early warning that order-flow pressure is fading and a potential turning point may be forming.
How it works
The script builds a continuous CVD line by requesting lower-timeframe candles with request.security_lower_tf and summing their delta (up-volume minus down-volume) on every bar, without resetting per session. It then detects swing highs and lows (pivots) on the CVD line and compares each pivot to the previous one against the matching price pivot.
What it detects
- Regular Bullish — price makes a lower low while CVD makes a higher low (selling pressure fading).
- Regular Bearish — price makes a higher high while CVD makes a lower high (buying pressure fading).
- Hidden Bullish / Hidden Bearish — trend-continuation variants, off by default.
Each confirmed divergence is drawn as a line connecting the two CVD pivots, with a label (Bull / Bear / H Bull / H Bear). Four alert conditions are included so you can be notified automatically.
Settings
- Lower timeframe — resolution used to estimate delta (default 1 min).
- Pivot left / right length — swing sensitivity. Smaller values = more signals; larger = fewer but stronger.
- Min / Max pivot distance — allowed spacing between the two pivots being compared.
- Show Regular / Show Hidden — toggle each divergence family.
How to use
Treat divergences as context, not a standalone entry. They work best near support/resistance, prior highs/lows, or other confluence. Signals confirm only after the pivot's right-side bars complete, so they appear with an inherent delay and the latest swing may not be confirmed yet.
Notes & limitations
Standard chart data contains no true bid/ask tick information, so delta is approximated from lower-timeframe candle direction. Results are most reliable on liquid instruments with genuine volume (futures, crypto, major equities) and on intraday timeframes — on high timeframes the available lower-timeframe history is limited. For analysis and educational purposes only; not financial advice.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.