Volume Weighted Moving Average (VWMA)
Summary
Volume Weighted Moving Average: the mean price over a trailing window of optInTimePeriod bars, each bar weighted by its own volume. Heavily traded bars pull the average toward their price; quiet bars barely move it.
Read like any moving average — price above is strength, below is weakness. Against a plain SMA of the same window it leads on high-volume moves and lags on low-volume drift, so the gap between the two lines measures how volume-confirmed a move is.
It has no attributable inventor — charting-package folklore — and every published definition agrees, so there is no competing variant.
Chart
Chart metadata i
Outputs
outReal:line
Formula
VWMA = ( sum_{k=t-N+1..t} P[k] * V[k] ) / ( sum_{k=t-N+1..t} V[k] ), N = optInTimePeriod
Equivalently, SMA(P * V, N) / SMA(V, N), the composition TradingView documents for ta.vwma. In TA-Lib the two are bit-identical for N of 2 or more, up to the first window whose volume is entirely zero. There is no seeding and no recursion, hence no unstable period.
Notes
- A period of 1 performs no smoothing: the output is a copy of the input, whatever the volume.
- Volume is expected to be non-negative. Individual zero-volume bars are fine: a bar that did not trade simply carries no weight, and the average stays well defined as long as some bar in the window has volume. At a period of 2 or more, a window in which every volume is zero has no weights at all; the weighted mean is then undefined and that element is NaN, as it is in every other implementation. Series carrying no volume on any bar, such as cash-index feeds, are outside what a volume-weighted average can describe — use SMA or WMA there.
Inputs
inReal— Source price series, close by conventioninVolume— Volume of each bar
Outputs
outReal— Volume weighted moving average of the input
Parameters
| Parameter | Type | Default | Accepted values | Description |
|---|---|---|---|---|
optInTimePeriod | integer | 30 | 1–100000 | Number of bars in the weighting window |
Properties
Numerical Stability: Start-Independent
| ✅ Overlap Input i |
| ☐ Independent Y-Axis |
| ☐ Candlestick |
| ☐ Display Shift |
| ✅ Can Output NaN or ±Inf i |
| ✅ Identity at Period 1 i |
| ☐ Uses Transcendental |
| ☐ Input Must Be Positive |
Example
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double series[252]; /* your data, oldest first */
double volume[252]; /* your data, oldest first */
double out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_VWMA( 0, n - 1, series, volume, 30, &outBegIdx, &outNBElement, out );
printf( "%d values from bar %d: [%.4f, ..., %.4f]\n", outNBElement, outBegIdx, out[0], out[outNBElement - 1] );use ta_lib::Core;
let series = 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.vwma(0, series.len() - 1, &series, &volume, 30, &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[] series = 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.vwma(0, series.length - 1, series, volume, 30, 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 series = 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.Vwma(0, series.Length - 1, series, volume, 30, outReal);
Console.WriteLine(FormattableString.Invariant($"{r.Count} values from bar {r.BegIdx}: [{outReal[0]:F4}, ..., {outReal[r.Count - 1]:F4}]"));import { vwma } from 'ta-lib';
const series = new Float64Array(252); // your data, oldest first
const volume = new Float64Array(252); // your data, oldest first
const { begIdx, values } = vwma(series, { volume }, { timePeriod: 30 });
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"
)
series := 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.VWMA(0, len(series)-1, series, volume, 30, 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: vwma.c · vwma.yaml
| Native | File |
|---|---|
| C | ta_VWMA.c |
| Rust | vwma.rs |
| Java | Core_VWMA.java |
| C# | Core_VWMA.cs |
| TypeScript | vwma.ts |
| Go | vwma.go |
Python: talib.VWMA (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 Moving Average
See Also
References
- VWMA has no separately documented originator; its definition is uniform across charting packages.
- MotiveWave, Volume Weighted Moving Average study documentation — the closest thing to a primary definition.
- TradingView, Volume Weighted Moving Average (VWMA) — documents the equivalence with SMA(price * volume) / SMA(volume).