CVD - Cumulative Volume Delta Candles

TradingView Updated   

This indicator displays cumulative ​volume delta in candle form. It uses intrabar information to obtain more precise ​volume delta information than methods using only the chart's timeframe.


Bar polarity

By bar polarity, we mean the direction of a bar, which is determined by looking at the bar's close vs its open.


Intrabars are chart bars at a lower timeframe than the chart's. Each 1H chart bar of a 24x7 market will, for example, usually contain 60 bars at the lower timeframe of 1min, provided there was market activity during each minute of the hour. Mining information from intrabars can be useful in that it offers traders visibility on the activity inside a chart bar.

Lower timeframes (LTFs)

A lower timeframe is a timeframe that is smaller than the chart's timeframe. This script uses a ​LTF to access intrabars. The lower the ​LTF, the more intrabars are analyzed, but the less chart bars can display ​CVD information because there is a limit to the total number of intrabars that can be analyzed.

Volume delta

The ​volume delta concept divides a bar's ​volume in "up" and "down" ​volumes. The delta is calculated by subtracting down ​volume from up ​volume. Many calculation techniques exist to isolate up and down ​volume within a bar. The simplest techniques use the polarity of interbar price changes to assign their ​volume to up or down slots, e.g., On Balance Volume or the Klinger Oscillator. Others such as Chaikin Money Flow use assumptions based on a bar's OHLC values. The most precise calculation method uses tick data and assigns the ​volume of each tick to the up or down slot depending on whether the transaction occurs at the bid or ask price. While this technique is ideal, it requires huge amounts of data on historical bars, which usually limits the historical depth of charts and the number of symbols for which tick data is available.

This indicator uses intrabar analysis to achieve a compromise between the simplest and most precise methods of calculating ​volume delta. In the context where historical tick data is not yet available on TradingView, intrabar analysis is the most precise technique to calculate ​volume delta on historical bars on our charts. Our Volume Profile indicators use it. Other ​volume delta indicators in our Community Scripts such as the Realtime 5D Profile use realtime chart updates to achieve more precise ​volume delta calculations, but that method cannot be used on historical bars, so those indicators only work in real time.

This is the logic we use to assign intrabar ​volume to up or down slots:
 • If the intrabar's open and close values are different, their relative position is used.
 • If the intrabar's open and close values are the same, the difference between the intrabar's close and the previous intrabar's close is used.
 • As a last resort, when there is no movement during an intrabar and it closes at the same price as the previous intrabar, the last known polarity is used.

Once all intrabars making up a chart bar have been analyzed and the up or down property of each intrabar's ​volume determined, the up volumes are added and the down volumes subtracted. The resulting value is ​volume delta for that chart bar.


CVD Candles

Cumulative ​Volume Delta Candles present ​volume delta information as it evolves during a period of time.

This is how each candle's levels are calculated:
 • open: Each candle's' open level is the cumulative ​volume delta for the current period at the start of the bar.
  This value becomes zero on the first candle following a ​CVD reset.
  The candles after the first one always open where the previous candle closed.
  The candle's high, low and close levels are then calculated by adding or subtracting a ​volume value to the open.
 • high: The highest ​​volume delta value found in intrabars. If it is not higher than the ​volume delta for the bar, then that candle will have no upper wick.
 • low: The lowest ​​volume delta value found in intrabars. If it is not lower than the ​volume delta for the bar, then that candle will have no lower wick.
 • close: The aggregated ​volume delta for all intrabars. If ​volume delta is positive for the chart bar, then the candle's close will be higher than its open, and vice versa.

The candles are plotted in one of two configurable colors, depending on the polarity of ​volume delta for the bar.

CVD resets

The "cumulative" part of the indicator's name stems from the fact that calculations accumulate during a period of time. This allows you to analyze the progression of ​volume delta across manageable chunks, which is often more useful than looking at ​volume delta cumulated from the beginning of a chart's history.

You can configure the reset period using the "CVD Resets" input, which offers the following selections:
 • None: Calculations do not reset.
 • On a fixed higher timeframe: Calculations reset on the higher timeframe you select in the "Fixed higher timeframe" field.
 • At a fixed time that you specify.
 • At the beginning of the regular session.
 • On a stepped higher timeframe: Calculations reset on a higher timeframe automatically stepped using the chart's timeframe and following these rules:

    Chart TF        ​HTF

     <  1min        1H
     <  3H          1D
     <= 12H         1W
     <  1W          1M
     >= 1W          1Y

The indicator's background shows where resets occur.

Intrabar precision

The precision of calculations increases with the number of intrabars analyzed for each chart bar. It is controlled through the script's "Intrabar precision" input, which offers the following selections:
 • Least precise, covering many chart bars
 • Less precise, covering some chart bars
 • More precise, covering less chart bars
 • Most precise, 1min intrabars

As there is a limit to the number of intrabars that can be analyzed by a script, a tradeoff occurs between the number of intrabars analyzed per chart bar and the chart bars for which calculations are possible.

Total ​volume candles

You can choose to display candles showing the total intrabar ​volume for the chart bar. This provides you with more context to evaluate a bar's ​volume delta by showing it relative to the sum of intrabar ​volume. Note that because of the reasons explained in the "NOTES" section further down, the total ​volume is the sum of all intrabar ​​volume rather than the ​volume of the bar at the chart's timeframe.

Total ​volume candles can be configured with their own up and down colors. You can also control the opacity of their bodies to make them more or less prominent. This publication's chart shows the indicator with total ​volume candles. They are turned off by default, so you will need to choose to display them in the script's inputs for them to plot.


Divergences occur when the polarity of ​volume delta does not match that of the chart bar. You can identify divergences by coloring the ​CVD candles differently for them, or by coloring the indicator's background.

Information box

An information box in the lower-left corner of the indicator displays the HTF used for resets, the ​LTF used for intrabars, and the average quantity of intrabars per chart bar. You can hide the box using the script's inputs.


The first thing to look at when analyzing ​CVD candles is the side of the zero line they are on, as this tells you if ​CVD is generally ​bullish or ​bearish. Next, one should consider the relative position of successive candles, just as you would with a price chart. Are successive candles trending up, down, or stagnating? Keep in mind that whatever trend you identify must be considered in the context of where it appears with regards to the zero line; an uptrend in a negative ​CVD (below the zero line) may not be as powerful as one taking place in positive ​CVD values, but it may also predate a movement into positive ​CVD territory. The same goes with stagnation; a trader in a long position will find stagnation in positive ​CVD territory less worrisome than stagnation under the zero line.

After consideration of the bigger picture, one can drill down into the details. Exactly what you are looking for in markets will, of course, depend on your trading methodology, but you may find it useful to:
  • Evaluate ​volume delta for the bar in relation to price movement for that bar.
  • Evaluate the proportion that ​​volume delta represents of total ​volume.
  • Notice divergences and if the chart's candle shape confirms a hesitation point, as a Doji would.
  • Evaluate if the progress of ​CVD candles correlates with that of chart bars.
  • Analyze the wicks. As with price candles, long wicks tend to indicate weakness.

Always keep in mind that unless you have chosen not to reset it, your ​CVD resets for each period, whether it is fixed or automatically stepped. Consequently, any trend from the preceding period must re-establish itself in the next.


Know your volume

Traders using ​volume information should understand the ​volume data they are using: where it originates and what transactions it includes, as this can vary with instruments, sectors, exchanges, timeframes, and between historical and realtime bars. The information used to build a chart's bars and display ​volume comes from data providers (exchanges, brokers, etc.) who often maintain distinct feeds for intraday and ​end-of-day (​EOD) timeframes. How ​volume data is assembled for the two feeds depends on how instruments are traded in that sector and/or the ​volume reporting policy for each feed. Instruments from crypto and forex markets, for example, will often display similar ​volume on both feeds. Stocks will often display variations because block trades or other types of trades may not be included in their intraday ​volume data. ​Futures will also typically display variations.

Note that as intraday vs ​EOD variations exist for historical bars on some instruments, differences may also exist between the realtime feeds used on intraday vs 1D or greater timeframes for those same assets. Realtime reporting rules will often be different from historical feed reporting rules, so variations between realtime feeds will often be different from the variations between historical feeds for the same instrument. The Volume X-ray indicator can help you analyze differences between intraday and ​EOD ​volumes for the instruments you trade.

If every unit of ​volume is both bought by a buyer and sold by a seller, how can ​volume delta make sense?

Traders who do not understand the mechanics of matching engines (the exchange software that matches orders from buyers and sellers) sometimes argue that the concept of ​volume delta is flawed, as every unit of ​volume is both bought and sold. While they are rigorously correct in stating that every unit of ​volume is both bought and sold, they overlook the fact that information can be mined by analyzing variations in the price of successive ticks, or in our case, intrabars.

Our calculations model the situation where, in fully automated order handling, market orders are generally matched to limit orders sitting in the order book. Buy market orders are matched to quotes at the ask level and sell market orders are matched to quotes at the bid level. As explained earlier, we use the same logic when comparing intrabar prices. While using intrabar analysis does not produce results as precise as when individual transactions — or ticks — are analyzed, results are much more precise than those of methods using only chart prices.

Not only does the concept underlying ​volume delta make sense, it provides a window on an oft-overlooked variable which, with price and time, is the only basic information representing market activity. Furthermore, because the calculation of ​volume delta also uses price and time variations, one could conceivably surmise that it can provide a more complete model than ones using price and time only. Whether or not ​volume delta can be useful in your trading practice, as usual, is for you to decide, as each trader's methodology is different.

For Pine Script™ coders

As our latest Polarity Divergences publication, this script uses the recently released request.security_lower_tf() Pine Script™ function discussed in this blog post. It works differently from the usual in that it can only be used at LTFs, and it returns an array containing one value per intrabar. This makes it much easier for programmers to access intrabar information.

Look first. Then leap.

Release Notes:
• Added a selection of resets on a fixed time or at the beginning of regular sessions.
• Added a selection for the lower timeframe that always uses the greatest amount of detail, i.e., 1min intrabars.
Release Notes:
• Added a new reset mode: "At the first visible chart bar". As you scroll or zoom your chart, it will reset the cumulative count at the leftmost visible bar.
• You can now change the color of the information box.
Release Notes:
• Added an optional line that plots the `close` of the candles. You can use it instead of the candles.
• Added an optional MA of the `close` of the candles, which will reset when CVD resets.
• Added more choices for the intrabar precision selection.
• You can now disable the plotting of the zero line, which can be helpful when CVD does not reset and values get quite large.
Release Notes:
• Additional LTF selections were added for 2min intrabars and 250 intrabars.
• You can now choose to calculate volume delta as a percentage of the bar's total volume. This can provide a useful perspective on volume delta.
 You will not be able to display total volume candles when using this new calculation mode.
• Resets can now be calculated on Supertrend or Aroon trend changes. This can help you assess if VD is confirming the trend.
 An up or down arrow is displayed on trend changes, to indicate the trend's direction.
• A warning now appears in the information box when an average of less that 5 intrabars is detected,
 to remind you that calculations are then less reliable.
Release Notes:
• Added Parabolic SAR as one of the trends available when resetting on trend changes.
• Added information on the quantity of chart bars covered by the script's calculations in the information box.
Release Notes:

This indicator was updated to include version 4 of the lower_tf library, which now supports seconds-based timeframes.

We've adjusted the stepped LTF calculation for "Less/More Precise" intrabar precision options according to the following table:

Chart Timeframe            Lower Timeframe

                    (24hr markets/non-24hr markets)

                     Less Precise     More Precise

    <= 1min              5S               1S
    <= 2min              10S              5S
    <= 3min              15S              10S     
    <= 5min              30S              15S
    <= 15min             1min             30S
    <= 1hr               3min             1min
    <  ​2hr               5min             2min
    <  4hr               15min            3min
    <  6hr               30min            5min
    <  12hr           (1hr/30min)     (10min/5min)
    <  1D             (​​2hr/30min)     (15min/5min)
    <  1W             (​12hr/​2hr)​      (​2hr/30min)
    >  1W                1D              ​ 12hr

The "Very/Most Precise" options now use a stepped LTF to request the highest precision possible while covering enough historical chart bars for usefulness.
The script calculates the LTF for these options as follows:

Chart Timeframe            Lower Timeframe

                    (24hr markets/non-24hr markets)

                     Very Precise     Most Precise

    <= 1hr               5S               1S
    <= ​2hr               15S              5S
    <= 4hr               30S              15S
    <= 12hr          (1min/30S)        (30S/15S)
    <  1D            (​​2min/1min)       (1min/30S)
    <  1W            (​15min/​5min)​      (​10min/3min)
    >  1W            (1hr/30min)       (30min/15min)

We've improved the code's readability by replacing array functions with equivalent methods.

Get $15 worth of TradingView Coins for you and a friend:

Read more about the new tools and features we're building for you:
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?