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.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน