VWAP, the volume-weighted average price, is one of the few indicators that institutional desks and retail day traders both watch closely, and for the same reason: it answers a question no simple moving average can. Instead of asking "what has price been lately," VWAP asks "what is the average price everyone actually paid today, weighted by how much traded at each level." That single shift, from weighting by time to weighting by volume, is what makes it a genuine price-and-volume indicator rather than a price-only one. This guide explains what VWAP measures, why it matters, and how to build it in Pine Script v6 on TradingView.
This is a coding tutorial, not trading advice. VWAP is a way to express a volume-weighted reference price in code, and understanding how it is built explains both why traders anchor to it and why it behaves the way it does through a session.
What VWAP measures
VWAP is the sum of price times volume across every bar in a session, divided by the total volume in that session. The price used at each bar is usually the typical price, the average of the high, low, and close, often written as hlc3. Because each bar's contribution is scaled by its volume, a large burst of trading at a particular price pulls the VWAP toward that level far more than a quiet bar does. The result is a single line that represents the volume-weighted center of the day's action.
The crucial detail is that VWAP resets at the start of each session. It is a cumulative calculation that builds up through the day and then starts fresh the next day. This is why VWAP is fundamentally an intraday tool: on a daily chart, a single day is one bar, so a session-anchored VWAP has little to say. On a five-minute chart, it traces the running average paid price from the open onward, which is exactly the context day traders care about.
| VWAP | Moving Average | |
|---|---|---|
| Weighting | By traded volume | By time (each bar equal or decayed) |
| Resets | Each session by default | Never, rolls continuously |
| Answers | Average price people actually paid | Smoothed recent price |
| Pine function | ta.vwap() | ta.sma() / ta.ema() |
Why traders use it
For institutions, VWAP is a benchmark. A desk tasked with buying a large position over the day wants to buy at or below the day's VWAP, because doing so means they paid less than the average participant, and their execution quality is often measured against it. That institutional attention is part of why the level matters to everyone else: a lot of size is being worked around it.
For discretionary traders, VWAP acts as a dynamic line of fair value. Price above VWAP suggests buyers have been in control since the open and the average holder is in profit; price below suggests the opposite. Many traders treat VWAP as intraday support or resistance, look to buy pullbacks to it in an up day, and use it as a line in the sand for whether to be long or short on the session. The honest caveat is that none of this is guaranteed. VWAP is a widely watched reference, not a force, and in a strong trending day price can leave it behind and never look back.
Building the indicator
Pine Script provides VWAP as a built-in function, so the indicator is short. The important thing is that ta.vwap automatically anchors to the session, so you do not have to manage the reset yourself. Here is the complete v6 code.
//@version=6
indicator("VWAP", overlay = true)
src = input.source(hlc3, "Source")
vwapValue = ta.vwap(src)
plot(vwapValue, "VWAP", color = color.blue, linewidth = 2)The single working line is ta.vwap(src), which returns the running session VWAP of the chosen source. The input.source(hlc3, "Source") lets you pick which price the calculation uses, defaulting to the typical price hlc3, though you could switch it to close if you prefer. Setting overlay = true draws the line on the price chart, where it belongs, since VWAP is measured in price units. One thing to know: VWAP requires volume data, so on a symbol with no reported volume the calculation cannot work and TradingView will warn you. If you want to see the price-times-volume accumulation done by hand, our VWAP calculator walks through the arithmetic with the Pine Script equivalent beside it.
Adding standard-deviation bands
Many traders plot bands above and below VWAP, similar in spirit to Bollinger Bands, to mark how far price has stretched from the volume-weighted average. Pine's ta.vwap() can return those bands directly when you ask for them.
//@version=6
indicator("VWAP With Bands", overlay = true)
src = input.source(hlc3, "Source")
mult = input.float(1.0, "Band Multiplier")
[vwapValue, upperBand, lowerBand] = ta.vwap(src, anchor = timeframe.change("1D"), stdev_mult = mult)
plot(vwapValue, "VWAP", color = color.blue, linewidth = 2)
plot(upperBand, "Upper Band", color = color.new(color.blue, 50))
plot(lowerBand, "Lower Band", color = color.new(color.blue, 50))Here ta.vwap() is called with two extra arguments and returns a tuple. The anchor argument controls when the calculation resets; timeframe.change("1D") is true on the first bar of each new day, which reproduces the standard daily session anchor. The stdev_mult argument turns on the band outputs, scaled by your multiplier. The bands widen when trading is volatile and price is scattered around the VWAP, and narrow when the session is orderly, giving a volume-aware sense of how extended price is.
A simple VWAP strategy
A common intraday approach uses VWAP as a directional filter: only take long setups while price is above VWAP, treating the line as the boundary between a bullish and bearish session. Here is a minimal version that enters on a pullback to VWAP within an up session.
//@version=6
strategy("VWAP Pullback", overlay = true, margin_long = 100, margin_short = 100)
vwapValue = ta.vwap(hlc3)
aboveVwap = close > vwapValue
touchedVwap = low <= vwapValue and close > vwapValue
if touchedVwap and aboveVwap
strategy.entry("Long", strategy.long)
if ta.crossunder(close, vwapValue)
strategy.close("Long")The touchedVwap condition looks for a bar whose low dipped to or below VWAP but whose close finished back above it, a pullback that held. The exit fires when price closes decisively below VWAP, signalling the session character has flipped. Because VWAP resets each day, this logic is meant for an intraday timeframe; on a daily or higher chart it will not behave as intended. If you plan to trade something like this live, be careful about signals that can change while a bar is still forming, a problem we cover in detail in our guide to repainting.
The honest pitfalls
The first pitfall is using VWAP on the wrong timeframe. Its session reset makes it an intraday indicator; applying it to a daily chart quietly produces a line that does not mean what you think. The second is treating VWAP as a hard support or resistance level that price must respect. It is a heavily watched reference, which gives it some self-fulfilling weight, but on trending days price routinely leaves it far behind. The third is forgetting the volume requirement, which is easy to overlook until you apply the script to a symbol that does not report volume and get nothing.
As always, judge any VWAP strategy across a meaningful sample rather than one good-looking session, and remember that a backtest of an intraday strategy on TradingView carries its own assumptions about fills, which our guide to how TradingView backtesting works unpacks.
Building it faster
Coding VWAP by hand, especially the banded and anchored variants, is a good way to understand how the reset and the volume weighting shape the line. When you already know the exact behavior you want, describing it in plain English is faster than wiring the arguments together. A tool like PineScripter generates the v6 code and fixes compile errors automatically by reading TradingView's error messages directly. You can compare it against other options in our roundup of the best AI Pine Script generators.
The takeaway
VWAP is the volume-weighted average price of a session, delivered by one function, ta.vwap(), that handles the session reset for you and can return deviation bands on request. Its value comes from weighting price by the volume that actually traded, which is why both institutions and day traders anchor to it. Use it on intraday timeframes, treat it as a reference rather than a rule, and test any strategy built on it across a real sample.
Disclaimer: PineScripter is a coding tool for Pine Script development. It does not provide financial advice and does not guarantee trading profits. Always backtest strategies thoroughly and understand the risks before live trading.