Returns the volume-weighted moving average: the mean of price times volume over length bars divided by the mean volume.
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
ta.vwma(source: series int/float, length: series int) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| source | series int/ | required | Series of prices to average, weighted by the bar's volume. |
| length | series int | required | Number 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.vwapresets by session;ta.vwmaslides a fixed window and never resets.
Example
//@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