TradingView
TradingView
2022년 12월 31일 오후 6시 53분

CVD - Cumulative Volume Delta (Chart) 

Apple Inc.NASDAQ

설명

█  OVERVIEW


This indicator displays cumulative ​volume delta (​CVD) as an on-chart oscillator. It uses intrabar analysis to obtain more precise ​volume delta information compared to methods that only use the chart's timeframe.

The core concepts in this script come from our first ​CVD indicator, which displays CVD​ values as plot candles in a separate indicator pane. In this script, CV​D values are scaled according to price ranges and represented on the main chart pane.



█  CONCEPTS


Bar polarity

Bar polarity refers to the position of the close price relative to the open price. In other words, bar polarity is the direction of price change.


Intrabars

[I]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 [I]lower timeframe is a timeframe that is smaller than the chart's timeframe. This script utilizes a LTF to analyze intrabars, or price changes within a chart bar. The lower the ​LTF, the more intrabars are analyzed, but the less chart bars can display information due to the limited number of intrabars that can be analyzed.


Volume delta

Volume delta is a measure that separates ​volume​ into "up" and "down" parts, then takes the difference to estimate the net demand for the asset. This approach gives traders a more detailed insight when analyzing volume​ and market sentiment. There are several methods for determining whether an asset's volume​ belongs in the "up" or "down" category. Some indicators, such as On Balance Volume​ and the Klinger Oscillator, use the change in price between bars to assign ​volume​ values to the appropriate category. Others, such as Chaikin Money Flow, make assumptions based on open, high, low, and close prices. The most accurate method involves using tick data to determine whether each transaction occurred at the bid or ask price and assigning the ​volume​ value to the appropriate category accordingly. However, this method requires a large amount of data on historical bars, which can limit the historical depth of charts and the number of symbols for which tick data is available.

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. This indicator uses intrabar analysis to achieve a compromise between simplicity and accuracy in calculating ​volume delta on historical bars. Our Volume Profile indicators use it as well. Other ​volume delta indicators in our Community Scripts, such as the Realtime 5D Profile, use real-time chart updates to achieve more precise ​volume delta calculations. However, these indicators aren't suitable for analyzing historical bars since they only work for real-time analysis.

This is the logic we use to assign intrabar ​volume to the "up" or "down" category:
 • 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 comprising a chart bar are analyzed, we calculate the net difference between "up" and "down" intrabar volume​ to produce the volume​ delta for the chart bar.



█  FEATURES


CVD resets

The "cumulative" part of the indicator's name stems from the fact that calculations accumulate during a period of time. By periodically resetting the volume​ delta accumulation, we can analyze the progression of ​volume delta across manageable chunks, which is often more useful than looking at ​volume delta accumulated 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 trend changes: Calculations reset on the direction change of either the Aroon indicator, Parabolic SAR, or Supertrend.
 • 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



Specifying intrabar precision

Ten options are included in the script to control the number of intrabars used per chart bar for calculations. The greater the number of intrabars per chart bar, the fewer chart bars can be analyzed.

The first five options allow users to specify the approximate amount of chart bars to be covered:
 • Least Precise (Most chart bars): Covers all chart bars by dividing the current timeframe by four.
  This ensures the highest level of intrabar precision while achieving complete coverage for the dataset.
 • Less Precise (Some chart bars) & More Precise (Less chart bars): These options calculate a stepped ​LTF in relation to the current chart's timeframe.
 • Very precise (2min intrabars): Uses the second highest quantity of intrabars possible with the 2min ​LTF.
 • Most precise (1min intrabars): Uses the maximum quantity of intrabars possible with the 1min ​LTF.

The stepped lower timeframe for "Less Precise" and "More Precise" options is calculated from the current chart's timeframe as follows:
Chart Timeframe Lower Timeframe Less Precise More Precise < 1hr 1min 1min < 1D 15min 1min < 1W ​2hr​ 30min > 1W 1D 60min


The last five options allow users to specify an approximate fixed number of intrabars to analyze per chart bar. The available choices are 12, 24, 50, 100, and 250. The script will calculate the LTF​ which most closely approximates the specified number of intrabars per chart bar. Keep in mind that due to factors such as the length of a ticker's sessions and rounding of the LTF​, it is not always possible to produce the exact number specified. However, the script will do its best to get as close to the value as possible.

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.


Display

This script displays raw or cumulative volume​ delta values on the chart as either line or histogram oscillator zones scaled according to the price chart, allowing traders to visualize volume​ activity on each bar or cumulatively over time. The indicator's background shows where CVD​ resets occur, demarcating the beginning of new zones. The vertical axis of each oscillator zone is scaled relative to the one with the highest price range, and the oscillator values are scaled relative to the highest volume​ delta. A vertical offset is applied to each oscillator zone so that the highest oscillator value aligns with the lowest price. This method ensures an accurate, intuitive visual comparison of volume​ activity within zones, as the scale is consistent across the chart, and oscillator values sit below prices. The vertical scale of oscillator zones can be adjusted using the "Zone Height" input in the script settings.

This script displays labels at the highest and lowest oscillator values in each zone, which can be enabled using the "Hi/Lo Labels" input in the "Visuals" section of the script settings. Additionally, the oscillator's value on a chart bar is displayed as a tooltip when a user hovers over the bar, which can be enabled using the "Value Tooltips" input.

Divergences occur when the polarity of ​volume delta does not match that of the chart bar. The script displays divergences as bar colors and background colors that can be enabled using the "Color bars on divergences" and "Color background on divergences" inputs.

An information box in the lower-left corner of the indicator displays the HTF used for resets, the ​LTF used for intrabars, the average quantity of intrabars per chart bar, and the number of chart bars for which there is LTF data. This is enabled using the "Show information box" input in the "Visuals" section of the script settings.



FOR Pine Script™ CODERS


 • This script utilizes `ltf()` and `ltfStats()` from the lower_tf library.
  The `ltf()` function determines the appropriate lower timeframe from the selected calculation mode and chart timeframe, and returns it in a format that can be used with request.security_lower_tf().
  The `ltfStats()` function, on the other hand, is used to compute and display statistical information about the lower timeframe in an information box.
 • The script utilizes display.data_window and display.status_line to restrict the display of certain plots.
  These new built-ins allow coders to fine-tune where a script’s plot values are displayed.
 • The newly added session.isfirstbar_regular built-in allows for resetting the ​CVD segments at the start of the regular session.
 • The VisibleChart library developed by our resident PineCoders team leverages the chart.left_visible_bar_time and chart.right_visible_bar_time variables to optimize the performance of this script.
  These variables identify the opening time of the leftmost and rightmost visible bars on the chart, allowing the script to recalculate and draw objects only within the range of visible bars as the user scrolls.
  This functionality also enables the scaling of the oscillator zones.
  These variables are just a couple of the many new built-ins available in the chart.* namespace.
  For more information, check out this blog post or look them up by typing "chart." in the Pine Script™ Reference Manual.
 • Our ta library has undergone significant updates recently, including the incorporation of the `aroon()` indicator used as a method for resetting ​CVD segments within this script.
  Revisit the library to see more of the newly added content!



Look first. Then leap.


릴리즈 노트

v2

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)


The code now displays `na` values on bars that don't contain intrabar data rather than a value of 0.

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


코멘트
immediateIguan41386
How do you trade with this?
PineCoders
@immediateIguan41386,

The comment section is a limited place to discuss how volume can provide valuable insights to your trading, but it is worth mentioning that CVD can be particularly useful as it reflects the net demand for a specific asset. Here are some tips to help you draw inferences from CVD values:

 • Analyze the side of the zero line CVD values are on to determine if CVD is generally bullish or bearish
 • Consider the relative position of successive values and whether they are trending up, down, or stagnating
 • Keep in mind that the trend must be considered in the context of where CVD values appear with regards to the zero line
 • Drill down into details by evaluating:
  • Volume delta in relation to price movement
  • Proportion of volume delta to total volume
  • Divergences and if the candle shape confirms a hesitation point
  • Correlation between the progress of CVD values and chart bars
  • Analysis of wicks relative to CVD values as long wicks tend to indicate weakness
  • Keep in mind that CVD resets for each period, so any trend from the preceding period must re-establish itself in the next.

We hope you find these tips helpful in your strategy research campaign. Happy trading!
e93octane
@immediateIguan41386, For me.... I use the divergence on the candles [they start to show you ahead of time that a change is about to happen in the direction] and the overall divergence [the histogram] to show me trend changes.... I was using a community footprint chart to show this to me but this is better :)
PineCoders
simonmcintosh1979
hi there! any tips on using this to trade??
PineCoders
@simonmcintosh1979, Hi please see the answer to the similar comment above.
DynamicSignalLab
what a beauty
PineCoders
AssassinsGrid
Great indicator! The use of intrabar analysis to provide accurate volume delta information is impressive. Thanks to the author for creating such a useful and innovative tool for traders on Tradingview.
PineCoders
@Good-Vibe, Thank you for your positive feedback! We appreciate your kind words and support.
더보기