Assign the intrabar sign, then sum the bar delta
TradingView documents this classification for its Volume Delta indicator: a close above the intrabar open gives positive volume; below gives negative volume. For equal open and close, compare with the preceding intrabar close. If that is also equal, carry forward the previous sign. Bar delta is the sum of those signed volumes.
- The volume delta indicator starts each chart bar at zero. CVD carries the accumulated result between bars in the same anchor period.
- An entire intrabar receives one sign. Trades in both directions can occur inside it, so the label cannot identify the initiating side of each trade.
Recalculate nine intrabars by hand
This invented fixture uses three-minute chart bars and one-minute intrabars. Prices are arbitrary; volumes are shares. A and B are the only Monday chart bars; C is the first Tuesday bar in the same week. Assume no omitted trading bars or missing volume. Both daily and weekly periods start at A, and the daily period restarts at C. These deliberately short sessions isolate the arithmetic.
- A has 100 positive shares and 100 negative shares: delta = 0 despite total volume of 200. B has 150 positive and 50 negative: delta = +100. C has 30 positive and 100 negative: delta = −70.
- B / 2 is flat but positive because its close is above the previous close. A / 3 and C / 2 retain a negative sign. Assigning zero to every flat intrabar would change this fixture.
- The example begins with a directional intrabar, so its initial sign is known. A custom implementation must state what happens when its first available intrabar is flat and has no prior sign.
| Chart bar / intrabar | Open → close | Volume | Sign reason | Signed volume | Running bar delta |
|---|
| A / 1 | 100 → 101 | 100 | Close > open | +100 | 100 |
| A / 2 | 101 → 100 | 60 | Close < open | −60 | 40 |
| A / 3 | 100 → 100 | 40 | Equal previous close; retain − | −40 | 0 |
| B / 1 | 100 → 101 | 120 | Close > open | +120 | 120 |
| B / 2 | 102 → 102 | 30 | Flat; close > previous 101 | +30 | 150 |
| B / 3 | 102 → 101 | 50 | Close < open | −50 | 100 |
| C / 1 | 101 → 100 | 80 | Close < open | −80 | −80 |
| C / 2 | 100 → 100 | 20 | Equal previous close; retain − | −20 | −100 |
| C / 3 | 100 → 101 | 30 | Close > open | +30 | −70 |
Compare daily and weekly anchor results
Within an anchor, CVD close = previous CVD close + bar delta. At a new anchor, use zero instead of the previous close. A CVD candle opens at that starting value; its high and low track the cumulative path during the bar. The following values include the opening point in that path.
- For C, the daily path is 0 → −80 → −100 → −70. The weekly path is 100 → 20 → 0 → 30. A positive weekly close of 30 can coexist with a negative current-bar delta of −70.
- Changing the anchor does not change the signed intrabars in this fixture. It changes which earlier deltas remain in the total.
- On your chart, inspect the first bar after the chosen anchor changes. Confirm the actual period boundary for that symbol and session; do not assume every daily reset means the stock-market cash open.
| Bar | Bar delta | Daily CVD O / H / L / C | Weekly CVD O / H / L / C |
|---|
| Monday A | 0 | 0 / 100 / 0 / 0 | 0 / 100 / 0 / 0 |
| Monday B | +100 | 0 / 150 / 0 / 100 | 0 / 150 / 0 / 100 |
| Tuesday C | −70 | 0 / 0 / −100 / −70 | 100 / 100 / 0 / 30 |
Separate anchor length from historical coverage
TradingView describes a tradeoff: finer intrabars preserve more price-path detail but cover fewer chart bars. Coarser intrabars extend coverage and can change the signed-volume estimate. Anchor length controls accumulation; it cannot restore unavailable intrabars. Measure the first usable timestamp for each configuration on your own chart.
- The 12,000-intrabar budget is an arithmetic assumption, not a TradingView plan limit or measured history. It assumes complete 60-minute chart bars: 12,000 / 60 = 200 and 12,000 / 12 = 1,000. Sessions, gaps and feed availability change real coverage.
- For a comparison log, record configuration, first available CVD timestamp, first complete anchor, and the same completed-bar close under each setup. Exclude a partial first anchor from cross-configuration comparisons.
- If the available history begins partway through a week, a weekly total cannot be verified from the weekly boundary. Shortening the anchor may yield a later complete period, but does not repair the earlier missing data.
| Illustrative setup | Intrabars per hourly bar | Coverage with assumed 12,000 intrabars | What resets |
|---|
| 1-minute intrabars; daily anchor | 60 | 200 hourly bars | Daily total |
| 5-minute intrabars; daily anchor | 12 | 1,000 hourly bars | Daily total |
| 1-minute intrabars; weekly anchor | 60 | 200 hourly bars | Weekly total |
| 5-minute intrabars; weekly anchor | 12 | 1,000 hourly bars | Weekly total |
Record a divergence when it becomes knowable
Use a declared rule before inspecting the result. This hypothetical bearish-divergence rule compares CVD closes sampled at two confirmed price swing highs within one anchor. A swing high must exceed the highs of two bars on each side. Equality fails the rule. Require the second price high to be higher and its sampled CVD close to be lower.
- Assume highs for bars 8 through 15 are 97, 99, 100, 98, 99, 102, 101, 100. Both pivots satisfy the strict two-bars-each-side test. The sampled CVD values are separate assumed inputs, not values calculated from those price highs.
- At bar 15 close, 102 > 100 and 300 < 400 confirm this defined divergence. Log the event at bar 15. A line drawn back to bar 13 must not imply that the event was available there.
- If bar 14 or 15 reaches 102 or higher, bar 13 fails this strict pivot test. If an anchor reset or missing CVD separates the pivots, discard the comparison under this rule.
- This rule samples CVD at price pivots; it does not require independent CVD pivots. A different pairing rule can produce different signals. Divergence alone specifies neither an entry price nor an exit, and a trend can continue after it.
| Price pivot | Price high | CVD close at pivot | Earliest confirmation |
|---|
| Bar 10 | 100 | 400 | Close of bar 12 |
| Bar 13 | 102 | 300 | Close of bar 15 |
Verify values before asking for an alert
Add the built-in Cumulative Volume Delta indicator in TradingView. Fix the symbol, chart interval and session; choose the Anchor period and an explicit custom lower timeframe. Record completed-bar values around a reset and a flat intrabar before testing divergence. A live value may change before the chart bar closes.
- Give the Pine Script AI Coding Agent the sign convention, lower timeframe, reset boundary and missing-data policy. Request visible bar delta, CVD close and anchor identifier so discrepancies can be located.
- For the example divergence, request two confirmed price pivots in the same complete anchor, CVD sampled at their timestamps, and an event only at the second pivot confirmation close. Keep pivot time and confirmation time as separate outputs.
- Ask for syntax checking, then compare the generated calculation with TradingView on matching timestamps. Syntax success does not prove numerical agreement, data completeness or profitable signals.
- If volume is unavailable, treat the result as unavailable. A zero-volume observation and an absent observation are different. Do not bridge a missing period with an assumed zero delta.