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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.