OPEN-SOURCE SCRIPT

Cumulative Volume Delta

115
Cumulative Volume Delta (CVD) Indicator
This indicator is a modification of the Trading View CVD indicator. Cumulative Volume Delta (CVD), which represents the net difference between up volume (volume traded as the price increases) and down volume (volume traded as the price decreases) over a chosen Anchor Period.

The data for the CVD calculation is requested using the built-in ta.requestVolumeDelta function from a lower timeframe to approximate the directional volume with greater precision. This lower timeframe is either automatically selected based on the chart's timeframe or can be customized by the user.

Key Features and Inputs
Anchor Period: Defines the period over which the volume delta is accumulated and plotted. The default is "1D" (Daily), but it can be changed to any higher timeframe (e.g., "1W" for Weekly) to analyze CVD across different cycles.

CVD Candle Plot: The calculated volume delta values are plotted as a custom candle, where:

The open and close of the CVD candle represent the volume delta at the start and end of the anchor period, respectively.

The high and low represent the maximum and minimum volume delta reached during that period.

Up/Down Coloring Logic: The color of the CVD candle is determined by the directional movement of the price during the anchor period, allowing traders to quickly correlate volume delta with price action. Users can select between two methods via the "Strong Up/Down Coloring" input:

Strong Up/Down (Default): The candle is colored bullish (Teal) if the current price closes above the previous bar's high or bearish (Red) if it closes below the previous bar's low. This logic highlights significant momentum.

Regular Up/Down: The candle is colored bullish (Teal) if the close is greater than the open (price moved up) or bearish (Red) if the close is less than the open (price moved down).

Lower Timeframe Selection: This determines the resolution of the up and down volume components.

By default, the script automatically selects an appropriate lower timeframe (e.g., "1" minute for intraday charts, "5" minutes for daily charts) to balance historical data availability with calculation precision.

An option is provided to customize this "Lower Timeframe" for advanced users seeking higher or lower resolution.

The CVD indicator is a powerful tool for analyzing order flow dynamics and assessing the genuine strength of price movements by comparing the aggregate buying pressure (up volume) against the selling pressure (down volume).

Technical Notes (Code Details)
Language: Pine Script® //version=6.

Function: Utilizes the ta.requestVolumeDelta() function with a user-defined anchorInput (default "1D") and a determined lowerTimeframe to retrieve the relevant delta data: [openVolume, maxVolume, minVolume, lastVolume].

Error Handling: Includes a check to confirm the symbol provides volume data, preventing runtime errors.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.