Sidechair

ta.vwma()

Browse the reference

Returns the volume-weighted moving average: the mean of price times volume over length bars divided by the mean volume.

Try it in the editor

ta.vwma computes sma(source * volume, length) / sma(volume, length). Bars with heavy volume pull the average toward their price, quiet bars barely move it.

Expect na until a full window of length bars exists. A bar with na volume or na source makes the result na until it leaves the window.

Syntax

Pine Script
ta.vwma(source: series int/float, length: series int) -> series float

Arguments

NameTypeDefaultDescription
sourceseries int/floatrequiredSeries of prices to average, weighted by the bar's volume.
lengthseries intrequiredNumber of bars in the window. A whole number of 1 or more.

Returns

series float: the volume-weighted average price over the window, or na while it is not full.

Remarks

  • On symbols with no volume data the result is na or unstable, because the divisor is zero.
  • ta.vwap resets by session; ta.vwma slides a fixed window and never resets.

Example

Pine ScriptVWMA beside SMAOpen in editor
//@version=6
indicator("VWMA vs SMA", overlay = true)
len = input.int(20, "Length", minval = 1)
plot(ta.vwma(close, len), "VWMA", color = color.navy, linewidth = 2)
plot(ta.sma(close, len), "SMA", color = color.silver)

See also

Runs on Sidechair