TradingView price and volume calculations

Time segmented volume: define the public proxy before using it

Time Segmented Volume (TSV) is a proprietary Worden oscillator that compares segments of price and volume. TC2000 explains its interpretation and smoothing controls without publishing its underlying calculation. For TradingView, this guide specifies a public proxy: sum volume × close-to-close price change over N bars, then plot an M-bar simple average. It does not claim to reproduce proprietary TSV values.

See the decision guide

What the public sources establish

TC2000 identifies TSV as proprietary and describes zero-line interpretation, divergence and moving-average smoothing. Its PCF examples call a built-in TSV series; that interface is not a disclosure of the raw formula. A public Quantitative Finance post presents the volume-times-price-change rolling sum with a separate simple average. We use that inspectable formula as a proxy, not as proof of equivalence to Worden TSV.

  • TradingView search results include community scripts named Time Segmented Volume by liw0 and vitelot. A matching indicator name does not establish matching source, initialization or smoothing.
  • When choosing a community version, record its author, revision and source before comparing values. A screenshot cannot reveal a protected calculation.
  • The example below adds an explicit missing-data policy and completed-bar output. Those choices are part of this implementation, not claims about TC2000 internals.

Segment price and volume, then smooth the rolling total

Let C(t) be the current close and V(t) its volume. Define q(t) = V(t) × [C(t) − C(t−1)]. For a positive integer N, P(t) is the sum of the latest N contributions, including q(t). The signal S(t) is the arithmetic mean of the latest M complete P values. Both N and M count chart bars, so changing the chart interval changes the time span.

  • A rising close contributes positively, a falling close negatively, and an unchanged close contributes zero. An unchanged close does not mean no trades occurred.
  • Once initialized, P(t) = P(t−1) + q(t) − q(t−N). An old observation leaving the window can move the oscillator even when the latest close is flat.
  • N valid contributions require N+1 closes. The signal needs another M−1 complete proxy values. There is no seed of zero for missing history.
  • Longer smoothing reduces short fluctuations but delays response. A positive proxy below its signal is still above zero; signal crossings and zero crossings are different events.

Recalculate five bars with N = 3 and M = 2

This hypothetical stock fixture starts with a preceding close of $100 at bar 0. All five subsequent bars are complete, volumes are shares, and no observations are missing. Contributions and proxy readings have units of price change × shares. They are not measured cash inflows.

  • At bar 3: P = 200 − 150 + 0 = 50. At bar 4: P = −150 + 0 + 240 = 90, and S = (50 + 90) / 2 = 70.
  • At bar 5: P = 0 + 240 − 90 = 150, and S = (90 + 150) / 2 = 120. Price fell while P rose because the earlier −150 contribution left the window.
  • A sixth flat close with valid volume contributes zero. Its P would remain 150 and S would become 150. Missing volume instead makes P and S unavailable under the policy below.
BarCloseVolumeq = volume × changeP: 3-bar sumS: 2-bar mean
1$102100+200UnavailableUnavailable
2$101150−150UnavailableUnavailable
3$10180050Unavailable
4$103120+2409070
5$10290−90150120

Why this proxy differs from OBV and PVT

TradingView documents OBV as cumulative signed volume and PVT as cumulative volume weighted by the fractional close change. This proxy weights volume by the signed price change in currency units and keeps only N bars. Those differences change both the scale and the way old observations affect readings.

  • For the first fixture bar, contributions are +200 for this proxy, +100 for OBV and +2 for PVT: 100 × (102−100)/100 = 2.
  • Doubling all prices while keeping volume fixed doubles this proxy. OBV contributions stay unchanged; PVT fractional changes also stay unchanged. Do not transfer numerical thresholds between them.
  • PVT requires a nonzero preceding close. The chosen proxy does not divide by price, but its values still depend on price units, adjustments and the volume feed.
SeriesCurrent contributionHistory retained
This public proxyV × (C − previous C)Latest N contributions
OBV+V on a rise; −V on a fall; 0 if flatCumulative total
PVTV × (C − previous C) / previous CCumulative total

A Pine Script v6 implementation with explicit gaps

Paste this indicator into the TradingView Pine Editor and add it to a standard candle chart. Defaults are N = 13 and M = 7, matching the lengths shown in the public formula; these are example settings, not optimized parameters. Set N = 3 and M = 2 when checking the arithmetic above. The script plots only confirmed chart bars and exposes the raw contribution in the Data Window.

  • The zero substitution is only an internal arithmetic placeholder. Separate invalid-count windows suppress any result that contains missing data, so an absent observation is never presented as a valid zero.
  • With N = 3, a missing contribution at bar 6 invalidates P at bars 6, 7 and 8. If all following inputs are valid, P resumes at bar 9; with M = 2, S resumes at bar 10.
  • Zero volume is valid and contributes zero. Negative or missing volume is invalid. Bars absent entirely from the feed cannot be detected by this check; the window counts available chart bars.
  • Create the desired alert in TradingView and choose Once Per Bar Close. The script declares conditions but does not create an alert for you. It has no divergence alerts or order execution.
Public price-volume proxy, not the proprietary TC2000 TSV formula. Syntax checking does not establish chart-value parity or useful trading signals.pine
//@version=6
indicator("Public TSV proxy: volume x price change", overlay=false)
length = input.int(13, "Rolling contribution bars", minval=1)
signalLength = input.int(7, "Signal SMA bars", minval=1)
valid = not na(close) and not na(close[1]) and not na(volume) and volume >= 0
contribution = valid ? volume * (close - close[1]) : na
invalidCount = math.sum(valid ? 0.0 : 1.0, length)
rollingTotal = math.sum(nz(contribution, 0.0), length)
proxy = invalidCount == 0 ? rollingTotal : na
invalidProxyCount = math.sum(na(proxy) ? 1.0 : 0.0, signalLength)
signalTotal = math.sum(nz(proxy, 0.0), signalLength)
signal = invalidProxyCount == 0 ? signalTotal / signalLength : na
crossUp = ta.crossover(proxy, 0.0)
crossDown = ta.crossunder(proxy, 0.0)
confirmedUp = barstate.isconfirmed and crossUp
confirmedDown = barstate.isconfirmed and crossDown
plot(barstate.isconfirmed ? proxy : na, "Public proxy", color=color.blue, style=plot.style_histogram)
plot(barstate.isconfirmed ? signal : na, "Signal SMA", color=color.orange, style=plot.style_linebr)
plot(barstate.isconfirmed ? contribution : na, "Raw contribution", display=display.data_window)
hline(0, "Zero", color=color.gray)
alertcondition(confirmedUp, "Proxy crosses above zero", "Public TSV proxy crossed above zero at bar close.")
alertcondition(confirmedDown, "Proxy crosses below zero", "Public TSV proxy crossed below zero at bar close.")

Define divergence without moving the event into the past

One reproducible bearish-divergence rule samples the unsmoothed proxy P at two confirmed price swing highs. Require each price high to be strictly greater than the highs of two bars before and two after it. Compare only finite P readings: the second price high must be higher and its sampled P lower. This is a proposed observation rule, separate from the code above.

  • These are assumed pivot samples, separate from the five-bar arithmetic fixture. Assuming both highs pass the strict neighborhood test, 103 > 100 and 250 < 400 establish the defined divergence only at bar 17 close.
  • If bar 16 or 17 reaches 103, the second pivot fails. If either proxy sample is missing, discard the comparison. Record pivot time and confirmation time separately.
  • Using the signal line instead of P, or matching independent oscillator pivots, creates a different rule. Divergence may persist while price keeps rising; it supplies no entry, stop, exit or reversal probability.
Assumed pivotPrice highP sampled at pivotEarliest known time
Bar 10100400Bar 12 close
Bar 15103250Bar 17 close

Compare the calculation before extending it with Pineify

Keep the same symbol and exchange feed, chart interval, session, price adjustments and N/M values. Compare raw contribution, rolling proxy and signal at completed timestamps in the Data Window. Include a flat close, a large price gap, an old spike leaving the window and a missing-volume case. Different feeds or synthetic candles can change the inputs before any code difference is involved.

  • A large gap multiplies the whole current volume by the close change. That can dominate the window; it does not identify trade direction or institutional buying.
  • Give the Pine Script AI Coding Agent this public formula, initialization and invalid-data policy. Ask it to expose intermediate values and preserve bar-close conditions when drafting a custom variant.
  • Request syntax checking explicitly. Compare generated values with this specified proxy on TradingView before adding a separate divergence alert. Do not request guaranteed replication of proprietary source from its name or chart image.
Where Pineify fits

Pine Script AI Coding Agent

Draft a Pine indicator from a specified public price-volume formula, inspect its intermediate outputs and request syntax checking before chart comparison.

Draft a public volume proxy

Frequently asked questions

Educational formula examples, not investment advice. Numerical fixtures are hypothetical. Time Segmented Volume is identified by TC2000 as a proprietary Worden indicator; this public proxy makes no equivalence or return guarantee.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.