Returns the volume-weighted average price of source, restarting whenever anchor is true, with optional standard deviation bands.
ta.vwap accumulates source * volume and volume from each anchor bar onward and divides the first total by the second. Everything before the anchor bar is dropped, so the line restarts at that bar's own price.
Pass stdev_mult as a third argument to get a tuple [vwap, upper, lower], where the bands sit stdev_mult volume-weighted standard deviations away from the line. Build the anchor from timeframe.change or any boolean series.
Syntax
ta.vwap(source: series int/float, anchor: series bool) -> series float
ta.vwap(source: series int/float, anchor: series bool, stdev_mult: series int/float) -> [series float, series float, series float]Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| source | series int/ | required | Price series to average, for example hlc3 or close. |
| anchor | series bool | required | Boolean series. A true bar starts a new accumulation; false continues the current one. |
| stdev_mult | series int/ | required | Number of volume-weighted standard deviations between the line and each band. |
Returns
series float: the volume-weighted average price since the latest anchor.[series float, series float, series float]: the VWAP, the upper band and the lower band.
Remarks
- On Sidechair: when anchor is left out, the accumulation restarts at the start of each trading session of the chart's market.
- The first bar of a restart returns that bar's source. Bars with zero volume add nothing; a restart on a zero-volume bar yields na.
Example
//@version=6
indicator("Anchored VWAP", overlay = true)
newDay = timeframe.change("D")
[vwap, upper, lower] = ta.vwap(hlc3, newDay, 1.0)
plot(vwap, "VWAP", color = color.orange, linewidth = 2)
plot(upper, "Upper", color = color.gray)
plot(lower, "Lower", color = color.gray)See also
Runs on Sidechair