ta.vwap() - Pine Script Function
ta.vwap()
Section titled “ta.vwap()”Overview
Section titled “Overview”Volume weighted average price.
Syntax
Section titled “Syntax”ta.vwap(source, anchor) → series floatParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| source | series int/float | Source used for the VWAP calculation. |
Returns
Section titled “Returns”A VWAP series, or a tuple [vwap, upper_band, lower_band] if stdev_mult is specified.
Remarks
Section titled “Remarks”- Calculations only begin the first time the anchor condition becomes true. Until then, the function returns na.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("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)