OPEN-SOURCE SCRIPT
Aktualisiert

Dual Volume Divergence Line

1 528
Dual Volume Divergence Line (DVD/Line)
🔹 Overview
The Dual Volume Divergence Line (DVD/Line) is a custom Pine Script™ indicator designed to identify potential trend reversals and continuations by analyzing volume and price divergences. This script is inspired by the original concept of the Dual Volume Divergence Index (DVDI) by DonovanWall and has been modified and enhanced by keremertem. Special thanks to DonovanWall for the original concept. The indicator combines volume-based calculations with price action to generate signals for bullish and bearish divergences, both normal and hidden. Below is a detailed breakdown of its components and functionality.

🔹 Key Features of the DVD/Line Indicator
1. Dual Volume Divergence Calculation:
- The indicator calculates two primary volume-based indices: the Positive Volume Index (PVI) and the Negative Volume Index (NVI).
- PVI measures the impact of volume on price when the price increases, while NVI measures the impact when the price decreases.
- These indices are used to detect divergences between volume and price, which can signal potential reversals or continuations.

2. Customizable Inputs:
- DVD Sampling Period: Adjusts the sensitivity of the indicator by controlling the lookback period for calculating the volume-weighted moving averages (VWMA) of PVI and NVI.
- Band Width: Defines the range for calculating the upper and lower bands, which act as dynamic support and resistance levels.
- Source: Allows users to select the price source (e.g., `hlc3`, `close`, etc.) for calculations.

3. Volume-Weighted Moving Averages (VWMA):
- Instead of using traditional moving averages, the script employs VWMA to smooth the PVI and NVI signals. This ensures that the indicator is more responsive to changes in volume.

4. Upper and Lower Bands:
- The upper and lower bands are calculated using the Root Mean Square (RMS) of the highest and lowest values of the DVD line over a user-defined period. These bands help identify overbought and oversold conditions.

5. Divergence Detection:
- The script identifies four types of divergences:
- Normal Bullish Divergence: Occurs when price makes a lower low, but the DVD line makes a higher low.
- Hidden Bullish Divergence: Occurs when price makes a higher low, but the DVD line makes a lower low.
- Normal Bearish Divergence: Occurs when price makes a higher high, but the DVD line makes a lower high.
- Hidden Bearish Divergence: Occurs when price makes a lower high, but the DVD line makes a higher high.
- These divergences are visually highlighted on the chart using labels.

6. Customizable Divergence Selection:
- Users can choose between two types of divergence calculations:
- DVDI: Based on the raw divergence values.
- DVD Line: Based on the smoothed DVD line.

7. Visual Enhancements:
- The DVD line is plotted with a color-coded scheme: blue when the DVD line is above its signal line (bullish) and pink when it is below (bearish).
- The upper and lower bands are displayed as step lines, making it easier to identify key levels.

🔹 How the Indicator Works

1. Volume-Based Calculations:
- The script starts by calculating the PVI and NVI based on the selected price source and volume data.
- PVI increases when the price rises, while NVI decreases when the price falls. These indices are then smoothed using VWMA to generate signals.

2. DVD Line Calculation:
- The DVD line is derived by combining the divergences of PVI and NVI. It is further smoothed using a Weighted Moving Average (WMA) and a linear regression line for trend analysis.

3. Divergence Detection:
- The script identifies pivot points in the DVD line and compares them with price action to detect divergences.
- Normal divergences indicate potential reversals, while hidden divergences suggest trend continuations.

4. Dynamic Bands:
- The upper and lower bands are calculated using RMS, which provides a more accurate representation of volatility compared to standard deviation or fixed-width bands.

5. Labeling:
- Divergences are labeled directly on the chart with clear text and color coding:
🟢 Bullish Divergence: Green label with "Bull".
🟩 Bearish Divergence: Red label with "Bear".
🔴 Hidden Bullish Divergence: Lime label with "hid.".
🟧 Hidden Bearish Divergence: Orange label with "hid.".

🔹 Unique Aspects of This Script

1. Volume-Weighted Smoothing:
- Unlike traditional divergence indicators that rely on simple moving averages, this script uses VWMA and WMA to ensure that volume plays a significant role in signal generation.

2. Dynamic Bands with RMS:
- The use of RMS for calculating bands provides a more adaptive and accurate representation of market conditions, especially in volatile markets.

3. Flexible Divergence Selection:
- Users can choose between raw divergence values (DVDI) or smoothed values (DVD Line), allowing for greater customization based on trading style.

4. Comprehensive Divergence Detection:
- The script detects both normal and hidden divergences, providing a complete picture of potential trend reversals and continuations.

5. User-Friendly Visuals:
- The color-coded DVD line and cross-style bands make it easy to interpret the indicator at a glance.

🔹 How to Use the Indicator

1. Trend Identification:
- Use the Middle Band and its color to identify the current trend. A green line suggests bullish momentum, while a red line indicates bearish momentum. Additionally, a bullish momentum may be indicated when the DVD line crosses up, and a bearish momentum may be indicated when it crosses down the Middle Band.

2. Divergence Trading:
- Look for divergences between the DVD line and price action. Normal divergences can be used for counter-trend trades, while hidden divergences can confirm trend continuations.

3. Band Breakouts:
- Monitor the upper and lower bands for potential breakout or reversal signals. A break above the upper band may indicate overbought conditions, while a break below the lower band may suggest oversold conditions.

4. Customization:
- Adjust the sampling period and band width to suit different timeframes and trading strategies. Shorter periods are more sensitive, while longer periods provide smoother signals.

🔹 Conclusion
The Dual Volume Divergence Line (DVD/Line) is a powerful and versatile indicator that combines volume analysis with price action to generate actionable trading signals. Its unique use of volume-weighted smoothing, dynamic bands, and comprehensive divergence detection sets it apart from traditional divergence indicators. Whether you're a day trader or a long-term investor, this tool can help you identify high-probability trading opportunities with greater accuracy and confidence.

📌 Disclaimer: This script is for educational purposes only and does not constitute financial advice. Always conduct your own analysis before making trading decisions.
Versionshinweise
Update Explanation
The "Dual Volume Divergence Line" indicator has been revamped to offer traders more control and flexibility while maintaining its core purpose of identifying volume-based divergences in price action. Here’s what’s new and why these updates matter:

Enhanced Customization Options: The settings now include a new "Trailing Length" parameter (defaulting to 3), which lets you adjust how tightly the trailing line follows the main DVD line. Sampling Period and Band Width now have sensible minimums (2) and refined defaults (17 and 12, respectively), making it easier to adapt the indicator to different markets or timeframes. The Multiplier is now a float (default 1.0) with a 0.5 step size, giving you finer control over the indicator’s sensitivity.

Improved Calculations: We’ve swapped out the volume-weighted moving average (VWMA) for a weighted moving average (WMA) in the PVI and NVI signal calculations. This tweak simplifies the math without sacrificing accuracy, ensuring smoother and more consistent results. The trailing line (Dvd2) now uses your chosen Trailing Length instead of a fixed value, so it better reflects the market’s rhythm.

Visual Upgrade: The DVD line’s color now shifts based on its position relative to the trailing line (not just the prior value), offering a clearer visual cue of momentum shifts. The bands and divergence labels remain optional and intuitive, with no clutter added.

Tighter Divergence Detection: The default Divergence Range is now 1 (down from 5), allowing the indicator to spot potential reversals faster. You can still tweak this to suit your style.

These updates make the indicator more adaptable and user-friendly, whether you’re scalping short-term moves or analyzing longer trends. It’s still built on the original Dual Volume Divergence concept but now with sharper tools to match today’s trading needs. Give it a spin and adjust the settings to see how it fits your strategy!

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.