OPEN-SOURCE SCRIPT
CVD Divergence & Volume Profile

This Pine Script indicator, named "CVD Divergence & Volume Profile," is designed to identify potential trading opportunities by combining Cumulative Volume Delta (CVD) divergence with Volume Profile levels and an optional Simple Moving Average (SMA) trend filter. It plots signals directly on the price chart.
Here's a breakdown of what each component does and how to potentially trade with it:
1. Cumulative Volume Delta (CVD) Divergence
What it does: CVD measures the cumulative difference between buying and selling volume. A rising CVD indicates more buying pressure, while a falling CVD indicates more selling pressure. Divergence occurs when the price action contradicts the CVD's direction, suggesting a potential shift in momentum or trend reversal.
Bearish Divergence: The price makes a higher high, but the CVD makes a lower high (or fails to make a new high). This suggests that despite the price increasing, the underlying buying pressure is weakening.
Bullish Divergence: The price makes a lower low, but the CVD makes a higher low (or fails to make a new low). This suggests that despite the price decreasing, the underlying selling pressure is weakening.
Visualization:
Red triangle pointing down on the chart indicates a Bearish Divergence signal.
Green triangle pointing up on the chart indicates a Bullish Divergence signal.
2. Volume Profile Levels (VAH, VAL, POC)
What it does: The indicator calculates simplified Volume Profile levels over a user-defined vp_range (number of candles). These levels represent areas where significant trading activity has occurred:
VAH (Value Area High): The upper boundary of the "Value Area," where 70% of the volume traded.
VAL (Value Area Low): The lower boundary of the "Value Area," where 70% of the volume traded.
POC (Point of Control): The price level within the vp_range where the most volume was traded.
Significance: These levels often act as significant support and resistance zones.
Visualization:
Orange lines for VAH and VAL.
Yellow line for POC.
Zone Proximity (zone_thresh): The indicator only generates divergence signals if the current close price is within a specified percentage zone_thresh of either VAH, VAL, or POC. This filters signals to areas of high liquidity and potential turning points.
3. Trend Filter (SMA)
What it does: This is an optional filter (use_trend_filter) that uses a Simple Moving Average (sma_period, default 200).
Significance: It helps ensure that divergence signals are traded in alignment with the broader market trend, potentially increasing their reliability.
For long signals (bullish divergence), the price (close) must be above the SMA (indicating an uptrend).
For short signals (bearish divergence), the price (close) must be below the SMA (indicating a downtrend).
Visualization: A blue line on the chart representing the SMA.
How to Trade with It (Potential Strategies)
The indicator aims to provide high-probability entry points by combining multiple confirming factors. Here's how you might interpret and trade the signals:
Identify Divergence: Look for the triangle signals on your chart (red for bearish, green for bullish).
Confirm Proximity to Volume Profile Levels: The signal itself confirms that the price is near a significant Volume Profile level (VAH, VAL, or POC). These are areas where price often reacts.
Bullish Signal (Green Triangle): This suggests buying momentum is returning after a price decline, especially when the price is near VAL or POC, which might act as support.
Bearish Signal (Red Triangle): This suggests selling momentum is increasing after a price rally, especially when the price is near VAH or POC, which might act as resistance.
Check Trend Alignment (SMA Filter):
For a long trade: You would ideally want to see a green triangle (bullish divergence) while the price is above the blue SMA line. This indicates a bullish divergence confirming a potential bounce within an existing uptrend.
For a short trade: You would ideally want to see a red triangle (bearish divergence) while the price is below the blue SMA line. This indicates a bearish divergence confirming a potential rejection within an existing downtrend.
Entry and Exit Considerations:
Entry: Consider entering a trade on the candle where the signal appears, or on the subsequent candle for confirmation.
Stop Loss: For a long trade, a logical stop-loss could be placed below the lowest point of the divergence, or below the VAL/POC if the signal occurred near it. For a short trade, above the highest point of the divergence or VAH/POC.
Take Profit: Targets could be set at the opposite Volume Profile level, previous swing highs/lows, or using a fixed risk-reward ratio.
Example Trading Scenario:
Long Trade: You see a green triangle (bullish divergence) printed on the chart. You notice the price is currently at the VAL (orange line). You check the blue SMA line and confirm that the price is above it (uptrend). This confluence of factors (bullish divergence, support at VAL, and uptrend) provides a strong potential long entry signal. You might enter, place your stop loss just below VAL, and target VAH or the next resistance level.
Short Trade: You see a red triangle (bearish divergence). The price is at the VAH (orange line). The price is also below the blue SMA line (downtrend). This suggests a potential short entry. You might enter, place your stop loss just above VAH, and target VAL or the next support level.
Here's a breakdown of what each component does and how to potentially trade with it:
1. Cumulative Volume Delta (CVD) Divergence
What it does: CVD measures the cumulative difference between buying and selling volume. A rising CVD indicates more buying pressure, while a falling CVD indicates more selling pressure. Divergence occurs when the price action contradicts the CVD's direction, suggesting a potential shift in momentum or trend reversal.
Bearish Divergence: The price makes a higher high, but the CVD makes a lower high (or fails to make a new high). This suggests that despite the price increasing, the underlying buying pressure is weakening.
Bullish Divergence: The price makes a lower low, but the CVD makes a higher low (or fails to make a new low). This suggests that despite the price decreasing, the underlying selling pressure is weakening.
Visualization:
Red triangle pointing down on the chart indicates a Bearish Divergence signal.
Green triangle pointing up on the chart indicates a Bullish Divergence signal.
2. Volume Profile Levels (VAH, VAL, POC)
What it does: The indicator calculates simplified Volume Profile levels over a user-defined vp_range (number of candles). These levels represent areas where significant trading activity has occurred:
VAH (Value Area High): The upper boundary of the "Value Area," where 70% of the volume traded.
VAL (Value Area Low): The lower boundary of the "Value Area," where 70% of the volume traded.
POC (Point of Control): The price level within the vp_range where the most volume was traded.
Significance: These levels often act as significant support and resistance zones.
Visualization:
Orange lines for VAH and VAL.
Yellow line for POC.
Zone Proximity (zone_thresh): The indicator only generates divergence signals if the current close price is within a specified percentage zone_thresh of either VAH, VAL, or POC. This filters signals to areas of high liquidity and potential turning points.
3. Trend Filter (SMA)
What it does: This is an optional filter (use_trend_filter) that uses a Simple Moving Average (sma_period, default 200).
Significance: It helps ensure that divergence signals are traded in alignment with the broader market trend, potentially increasing their reliability.
For long signals (bullish divergence), the price (close) must be above the SMA (indicating an uptrend).
For short signals (bearish divergence), the price (close) must be below the SMA (indicating a downtrend).
Visualization: A blue line on the chart representing the SMA.
How to Trade with It (Potential Strategies)
The indicator aims to provide high-probability entry points by combining multiple confirming factors. Here's how you might interpret and trade the signals:
Identify Divergence: Look for the triangle signals on your chart (red for bearish, green for bullish).
Confirm Proximity to Volume Profile Levels: The signal itself confirms that the price is near a significant Volume Profile level (VAH, VAL, or POC). These are areas where price often reacts.
Bullish Signal (Green Triangle): This suggests buying momentum is returning after a price decline, especially when the price is near VAL or POC, which might act as support.
Bearish Signal (Red Triangle): This suggests selling momentum is increasing after a price rally, especially when the price is near VAH or POC, which might act as resistance.
Check Trend Alignment (SMA Filter):
For a long trade: You would ideally want to see a green triangle (bullish divergence) while the price is above the blue SMA line. This indicates a bullish divergence confirming a potential bounce within an existing uptrend.
For a short trade: You would ideally want to see a red triangle (bearish divergence) while the price is below the blue SMA line. This indicates a bearish divergence confirming a potential rejection within an existing downtrend.
Entry and Exit Considerations:
Entry: Consider entering a trade on the candle where the signal appears, or on the subsequent candle for confirmation.
Stop Loss: For a long trade, a logical stop-loss could be placed below the lowest point of the divergence, or below the VAL/POC if the signal occurred near it. For a short trade, above the highest point of the divergence or VAH/POC.
Take Profit: Targets could be set at the opposite Volume Profile level, previous swing highs/lows, or using a fixed risk-reward ratio.
Example Trading Scenario:
Long Trade: You see a green triangle (bullish divergence) printed on the chart. You notice the price is currently at the VAL (orange line). You check the blue SMA line and confirm that the price is above it (uptrend). This confluence of factors (bullish divergence, support at VAL, and uptrend) provides a strong potential long entry signal. You might enter, place your stop loss just below VAL, and target VAH or the next resistance level.
Short Trade: You see a red triangle (bearish divergence). The price is at the VAH (orange line). The price is also below the blue SMA line (downtrend). This suggests a potential short entry. You might enter, place your stop loss just above VAH, and target VAL or the next support level.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。