Price Volume Trend (PVT)
Summary
Price Volume Trend: a running cumulative total of each bar's volume weighted by that bar's fractional price change. It is the On Balance Volume idea with partial credit — where OBV adds or subtracts a bar's whole volume on the sign of the move, PVT adds only the fraction of that volume proportional to the size of the move.
Read the slope and the divergences, not the level: the total's zero point is arbitrary, so only the shape of the curve carries information. A rising PVT while price is flat says volume is accumulating on the up moves; a falling PVT while price rises is the classic bearish divergence.
Chart
Chart metadata i
Outputs
outReal:line·zero·positive·negative
Formula
PVT[i] = PVT[i-1] + inVolume[i] * (inClose[i] - inClose[i-1]) / inClose[i-1]
The series starts at zero on the first bar of the requested range.
Notes
- The input is assumed positive. The previous close is the divisor. Near zero the divisor is small and the output very large; no error is returned. A series that reaches or crosses zero, such as an oscillator or a spread, has no meaningful result here.
- The absolute level is arbitrary and depends on where the accumulation started, so two ranges over the same data give curves of the same shape at different offsets.
- Some libraries scale the per-bar term by 100. This implementation follows the fractional definition, which every primary reference below states.
- A bar whose previous close is exactly zero contributes nothing and the running total is carried forward unchanged, rather than dividing by zero. A flat stretch of the output can therefore mean either genuine zero net accumulation or a run of zero previous closes.
Inputs
inClose— Close price of each barinVolume— Volume of each bar
Outputs
outReal— Cumulative price volume trend, seeded at zero
Properties
Numerical Stability: Path-Dependent
| ☐ Overlap Input |
| ✅ Independent Y-Axis i |
| ☐ Candlestick |
| ☐ Display Shift |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ☐ Uses Transcendental |
| ✅ Input Must Be Positive i |
Example
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double close[252]; /* your data, oldest first */
double volume[252]; /* your data, oldest first */
double out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_PVT( 0, n - 1, close, volume, &outBegIdx, &outNBElement, out );
printf( "%d values from bar %d: [%.4f, ..., %.4f]\n", outNBElement, outBegIdx, out[0], out[outNBElement - 1] );use ta_lib::Core;
let close = vec![0.0; 252]; // your data, oldest first
let volume = vec![0.0; 252]; // your data, oldest first
let mut out = vec![0.0; 252];
let core = Core::new();
let range = core.pvt(0, close.len() - 1, &close, &volume, &mut out)?;
println!("{} values from bar {}: [{:.4}, ..., {:.4}]", range.count, range.beg_idx, out[0], out[range.count - 1]);import io.github.talib.Core;
import io.github.talib.OutRange;
import java.util.Locale;
double[] close = new double[252]; // your data, oldest first
double[] volume = new double[252]; // your data, oldest first
double[] out = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.pvt(0, close.length - 1, close, volume, out);
System.out.printf(Locale.ROOT, "%d values from bar %d: [%.4f, ..., %.4f]%n", r.count(), r.begIdx(), out[0], out[r.count() - 1]);using System;
using TALib;
var close = new double[252]; // your data, oldest first
var volume = new double[252]; // your data, oldest first
var outReal = new double[252];
var core = Core.Default;
OutRange r = core.Pvt(0, close.Length - 1, close, volume, outReal);
Console.WriteLine(FormattableString.Invariant($"{r.Count} values from bar {r.BegIdx}: [{outReal[0]:F4}, ..., {outReal[r.Count - 1]:F4}]"));import { pvt } from 'ta-lib';
const close = new Float64Array(252); // your data, oldest first
const volume = new Float64Array(252); // your data, oldest first
const { begIdx, values } = pvt({ close, volume });
console.log(values.length + ' values from bar ' + begIdx + ': [' + values[0].toFixed(4) + ', ..., ' + values[values.length - 1].toFixed(4) + ']');import (
"fmt"
"log"
talib "ta-lib.github.io/go"
)
close := make([]float64, 252) // your data, oldest first
volume := make([]float64, 252) // your data, oldest first
out := make([]float64, 252)
core := talib.NewCore()
r, err := core.PVT(0, len(close)-1, close, volume, out)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d values from bar %d: [%.4f, ..., %.4f]\n", r.NBElement, r.BegIdx, out[0], out[r.NBElement-1])Implementation
Added in 0.8.1 (ta-lib-python 0.8.1).
TA-Lib Definition: pvt.c · pvt.yaml
| Native | File |
|---|---|
| C | ta_PVT.c |
| Rust | pvt.rs |
| Java | Core_PVT.java |
| C# | Core_PVT.cs |
| TypeScript | pvt.ts |
| Go | pvt.go |
Python: talib.PVT (ta-lib-python 0.8.1 or later), see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
Price Volume Trend, Volume Price Trend, VPT