Volume Weighted Average Price (VWAP)
Summary
Volume Weighted Average Price: the average price paid per unit of volume traded, accumulated from the first bar of the range onward. Because every bar is weighted by the volume that traded on it, VWAP tracks where the bulk of the money actually changed hands rather than where the last trade printed. Price above VWAP is read as buyers paying up relative to the session's average cost, price below it as the reverse, which is why execution desks quote fills against it.
VWAP is a running mean, not a moving average: it has no window and no decay, so each new bar carries a smaller share of the total and the line grows steadily more sluggish the further it runs from its anchor. It stays within the range of the typical prices it averages, but over a long trending range it can sit far from the current price.
Chart
Chart metadata i
Outputs
outReal:line
Formula
TP_t = ( High_t + Low_t + Close_t ) / 3; VWAP_t = ( Σ TP · Volume ) / ( Σ Volume ), both sums running from the first bar of the range
Notes
- The sums run from the first bar of the range and are never reset. Charting packages anchor VWAP to a trading session and restart it at each session boundary; no TA-Lib function takes a timestamp or a session boundary, so the anchor is the range the caller asks for — pass one session's bars to get that session's VWAP. This is how AD and OBV, the other cumulative volume functions, are already used across sessions.
- Volume is expected to be non-negative. A zero-volume bar carries no weight, so one occurring after volume has traded leaves the average exactly where it was. Before any volume has traded there are no weights at all and the weighted mean is undefined; those bars carry the previous value forward, which is 0 until the first bar with volume. A successful call never emits NaN or ±Inf. Other implementations differ here: pandas-ta-classic divides through and emits NaN, and trading-signals emits no value for the bar at all.
- A bar whose price or volume is not a finite number cannot be weighted, so it is left out of the average entirely and repeats the previous value. It is skipped, not absorbed: the running average stays usable and resumes on the next bar that can be weighted, rather than being held at one stale value for the remainder of the range.
Inputs
inHigh— High price of each barinLow— Low price of each barinClose— Close price of each barinVolume— Volume of each bar
Outputs
outReal— Volume weighted average price, cumulative from the first bar of the range
Properties
Numerical Stability: Path-Dependent
| ✅ Overlap Input i |
| ☐ Independent Y-Axis |
| ☐ Candlestick |
| ☐ Display Shift |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ☐ Uses Transcendental |
| ☐ Input Must Be Positive |
Example
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double high[252]; /* your data, oldest first */
double low[252]; /* your data, oldest first */
double close[252]; /* your data, oldest first */
double volume[252]; /* your data, oldest first */
double out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_VWAP( 0, n - 1, high, low, close, volume, &outBegIdx, &outNBElement, out );
printf( "%d values from bar %d; last out = %f\n", outNBElement, outBegIdx, out[outNBElement - 1] );use ta_lib::Core;
let high = vec![0.0; 252]; // your data, oldest first
let low = vec![0.0; 252]; // your data, oldest first
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.vwap(0, high.len() - 1, &high, &low, &close, &volume, &mut out)?;
println!("{} values from bar {}; last out = {}", range.count, range.beg_idx, out[range.count - 1]);import io.github.talib.Core;
import io.github.talib.OutRange;
double[] high = new double[252]; // your data, oldest first
double[] low = new double[252]; // your data, oldest first
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.vwap(0, high.length - 1, high, low, close, volume, out);
System.out.println(r.count() + " values from bar " + r.begIdx() + "; last out = " + out[r.count() - 1]);using System;
using TALib;
var high = new double[252]; // your data, oldest first
var low = new double[252]; // your data, oldest first
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.Vwap(0, high.Length - 1, high, low, close, volume, outReal);
Console.WriteLine($"{r.Count} values from bar {r.BegIdx}; last outReal = {outReal[r.Count - 1]}");import { vwap } from 'ta-lib';
const high = new Float64Array(252); // your data, oldest first
const low = new Float64Array(252); // your data, oldest first
const close = new Float64Array(252); // your data, oldest first
const volume = new Float64Array(252); // your data, oldest first
const { begIdx, values } = vwap({ high, low, close, volume });
console.log(values.length + ' values from bar ' + begIdx + '; last values = ' + values[values.length - 1]);Implementation
Added in 0.8.1 (ta-lib-python 0.8.1).
TA-Lib Definition: vwap.c · vwap.yaml
| Native | File |
|---|---|
| C | ta_VWAP.c |
| Rust | vwap.rs |
| Java | Core_VWAP.java |
| C# | Core_VWAP.cs |
| TypeScript | vwap.ts |
Python: talib.VWAP (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
Volume Weighted Average Price
See Also
References
- No single attributable author: VWAP is charting-package convention rather than a published indicator, and the sources below all state the same definition.
- Investopedia, Volume-Weighted Average Price (VWAP): the typical price of each bar weighted by that bar's volume, cumulated over the trading day: investopedia.com/terms/v/vwap.asp
- StockCharts ChartSchool, VWAP Intraday: the same cumulative form, and the source of the session-reset convention: stockcharts.com/school
- TradingView, Volume Weighted Average Price:
VWAP = cumulative(typical price x volume) / cumulative(volume), anchored to the session: tradingview.com/wiki - pandas-ta-classic
overlap/vwap.pystates the core form verbatim in its own docstring,VWAP = tpv.cumsum() / volume.cumsum(), and reaches the session reset only by grouping on aDatetimeIndex. trading-signalstrend/VWAPimplements the cumulative form with no anchor at all.