Moving AveragesPine Script v6

ta.vwma()Volume Weighted Moving Average

Computes the volume-weighted moving average (VWMA): over the last length bars, each source value is weighted by volume. Heavier volume bars pull the average more, tying the trend line to where participation was largest.

TradingView language reference

Syntax

Syntax
ta.vwma(source, length) → series float

Arguments

ParameterTypeDescription
sourceseries int/floatSeries of values to process (often close).
lengthseries intNumber of bars (length).

Returns

Volume weighted moving average of source for length bars back.

Remarks

na source values are ignored. Volume availability and meaning depend on the feed; a zero total weight makes a weighted mean undefined. The illustrative ratio assumes aligned valid inputs and is not a full missing-data equivalence test.

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.vwma")
plot(ta.vwma(close, 15))

// same on pine, but much less efficient
pine_vwma(x, y) =>
    ta.sma(x * volume, y) / ta.sma(volume, y)
plot(pine_vwma(close, 15))

Trading Applications

Incorporate volume into trend analysis

Compare volume-weighted and equal-weighted source averages

Compare VWMA with SMA to detect volume-driven moves

Use as a dynamic support/resistance with volume confirmation

Frequently Asked Questions

ta.vwma() averages price (or any source) over length bars, weighting each bar by its volume. It is equivalent in spirit to sum(price*volume)/sum(volume) over the window.

SMA ignores volume. VWMA gives more weight to source values on higher-volume bars. Weighting a bar close by its entire volume does not reconstruct the prices of all trades or identify institutional buying/selling.

VWMA helps when volume meaningfully varies—e.g., spotting whether price is holding above an average that reflects heavy participation, or diverging from a volume-agnostic SMA.

Generate ta.vwma() Code with AI

Draft Pine Script using ta.vwma() with Pineify's AI Coding Agent, then review the arguments and test the result on your chart. Usage depends on your plan and available credits.