Skip to content
Algo Trade Analytics Docs

ta.vwap() - Pine Script Function

Volume weighted average price.

ta.vwap(source, anchor) → series float
NameTypeDescription
sourceseries int/floatSource used for the VWAP calculation.

A VWAP series, or a tuple [vwap, upper_band, lower_band] if stdev_mult is specified.

  • Calculations only begin the first time the anchor condition becomes true. Until then, the function returns na.
//@version=6
indicator("Advanced VWAP")
vwapAnchorInput = input.string("Daily", "Anchor", options = ["Daily", "Weekly", "Monthly"])
stdevMultiplierInput = input.float(1.0, "Standard Deviation Multiplier")
anchorTimeframe =
switch vwapAnchorInput "Daily" => "1D" "Weekly" => "1W" "Monthly" => "1M"anchor = timeframe.change(anchorTimeframe)[vwap, upper, lower] = ta.vwap(open, anchor, stdevMultiplierInput)
plot(vwap)
plot(upper, color = color.green)
plot(lower, color = color.green)