VWAP indicator: formula, session reset and an NQ backtest with costs
VWAP is the session's average price weighted by volume, rebuilt from zero at every session open. On futures the session you choose decides the line, so the chart session and the backtest session must match. A close-above-VWAP rule flips often, so judge it by its average trade after commission and slippage.
By Soren Huang · Published · updated · Editorial policy
Contents
- What is the VWAP indicator and how is it calculated?
- When does VWAP reset on futures, and why do day and night sessions matter?
- How does VWAP differ from a moving average?
- How do traders use VWAP in trading: trend filter, mean reversion or benchmark?
- How do anchored VWAP and VWAP bands change the line?
- What does a close-above-VWAP rule look like in a backtest with costs?
- Frequently asked questions
- References
What is the VWAP indicator and how is it calculated?
The VWAP indicator is the average price of the current session weighted by volume: add up typical price times volume for every bar since the session opened, divide by the total volume, and start again from zero at the next open. On futures the session you choose decides the line, and any VWAP rule must be judged by its average trade after costs.
VWAP (volume-weighted average price) is the price at which the average contract of the session changed hands. Think of a market stall that sells apples all morning at slightly different prices. The stall's average selling price is not the average of the price tags; it is total money taken divided by total apples sold. Busy hours count for more than quiet hours. VWAP does the same with bars: a bar with heavy volume pulls the line toward its price, a bar with light volume barely moves it.
The one formula to know:
VWAP = Σ(typical price × volume) ÷ Σ(volume)
Here typical price is the average of a bar's high, low and close, volume is the number of contracts traded in that bar, and Σ means "add up every bar since the session opened". Both sums grow bar by bar until the session ends, then both go back to zero.
Hypothetical example
Five bars after the open, with typical price and volume: 100 × 200, 101 × 400, 99 × 100, 102 × 300, 101 × 500. Running price × volume: 20,000, then 60,400, 70,300, 100,900, 151,400. Running volume: 200, 600, 700, 1,000, 1,500. VWAP after each bar: 100.00, 100.67, 100.43, 100.90, 100.93. The third bar at 99 barely moves the line because only 100 contracts traded there; the fifth bar at 101 moves it more because 500 traded.
When does VWAP reset on futures, and why do day and night sessions matter?
On a futures contract that trades almost around the clock, VWAP resets wherever you tell the chart the session starts, so a day-session VWAP and a full-session VWAP draw two different lines on the same bars. A stock has one obvious open. NQ (E-mini Nasdaq-100 futures) trades through the night with only a short daily break, so "the open" is a choice: the night open after the daily break, or the open of the US day session.
The two choices give different lines for a simple reason. A full-session VWAP has already absorbed hours of night volume when the day session begins, so it starts the day near the night's average price. A day-session VWAP starts at the first day bar's typical price and has no memory of the night. In the first hours after the day open the two lines can sit far apart, and a rule that reads "close above VWAP" can be long on one chart and short on the other at the same moment. Later in the day, as day volume dominates both sums, the lines usually move closer.
- Choose the session before you draw anything. Day-only or full-session is a research decision, not a chart cosmetic.
- Use the same session in the chart and in the backtest. A rule designed on a day-session chart and tested on full-session bars tests a different indicator. Day-only vs full-session bars in night session backtests covers what else changes.
- Check the session template on your charting platform. On TradingView, for example, the VWAP indicator settings include an anchor period; set it to match the session your test uses.
Exchanges can change session hours, so the exchange's contract page is the reference, and the free futures market hours tool shows the current sessions in your own time zone. The NQ contract itself is described in NQ and MNQ futures specs, sessions and backtest costs.
How does VWAP differ from a moving average?
A moving average weights the last N bars equally and never resets; VWAP weights every bar of the current session by its volume and forgets everything at the open. A moving average is a line that shows the average close of a fixed number of recent bars, dropping the oldest bar as each new one arrives. The two lines can look alike early in a quiet session and then drift apart after a burst of volume.
| Property | Moving average | VWAP |
|---|---|---|
| Weighting | Equal per bar (or by age for an EMA) | By volume of each bar |
| Lookback | Last N bars | All bars since the session start |
| Reset | Never | At the session open |
| Value at the first bar of a session | Carries over from yesterday | Equals the first bar's typical price |
| After one high-volume bar | Moves a little, like any bar | Pulled toward that bar's price |
| Main setting | Length N | Session start (anchor) |
This difference also tells you what VWAP is not. It is not an oscillator with fixed bounds like RSI and its 70/30 levels, the KD indicator built from the stochastic formula or the MACD calculation from two moving averages. Those indicators say "stretched" or "turning" on a scale. VWAP is a price, and a rule built on it compares price with price. The broader map of which tools can be written as rules and tested is in technical analysis tools and indicators: which can you test.
How do traders use VWAP in trading: trend filter, mean reversion or benchmark?
VWAP does three different jobs, and each job needs its own test design. The same line is read as a side filter, as a level price returns to, or as a yardstick for your own fills. A trader who mixes the three in one rule cannot tell which part of the result came from which idea.
| Use | The rule in one sentence | What the test must measure |
|---|---|---|
| Trend filter | Only take longs while price is above VWAP, only shorts while below | The base strategy with and without the filter, same costs, same period; trade count will fall, so compare average trade, not total |
| Mean reversion | Fade a stretch away from VWAP and exit when price returns to the line | How far "a stretch" is (in ticks or bands), how often price never returns before the session ends, and the loss on those trades |
| Execution benchmark | Compare your average fill with the session VWAP | No strategy test at all; a record of fills versus VWAP over many sessions |
The filter and the fade pull in opposite directions. The filter assumes price that is above VWAP tends to stay above; the fade assumes price that is far above VWAP tends to come back. Both can be true at different distances from the line, which is why the fade needs a distance setting and the filter does not. Mean reversion explained with a testable futures example shows how to write the distance and the exit so the test is fair. The benchmark use needs no backtest: it is a bookkeeping habit that tells you whether your entries are costing you more than the session average.
How do anchored VWAP and VWAP bands change the line?
Once the session is fixed, the anchor bar and the band multiplier are the two settings that move a VWAP signal. Standard VWAP anchors at the session open and restarts every day. Anchored VWAP is a VWAP whose sums start at a bar the trader picks, such as a swing low or a news bar, and run across days without resetting. VWAP bands are lines drawn a chosen multiple of the volume-weighted spread above and below the VWAP line, so a multiplier of 2 draws bands twice as far out as a multiplier of 1.
The anchor changes what the line means. A session VWAP answers "what did today's average trader pay". An anchored VWAP from a swing low answers "what did the average trader who bought since that low pay", which is why some traders read it as a level where those buyers defend. On TradingView and other charting platforms, anchored VWAP is drawn by clicking the start bar; in a backtest the anchor must be a rule (for example, the lowest low of the last 20 bars), or it cannot be reproduced. The test of such a rule is in anchored VWAP rules tested on ES futures.
The band multiplier changes how often a fade rule fires. Narrow bands give many signals with small stretches; wide bands give few signals with large stretches. A fade rule that only works at one multiplier, and fails at the neighbouring values, is describing noise in the test period rather than a repeatable pattern. How VWAP bands are calculated and what a backtest shows walks through the multiplier test.
What does a close-above-VWAP rule look like in a backtest with costs?
The run shown here tests a Moving Average rule as a stand-in for the close-above-VWAP rule; it does not test VWAP itself. The reason is the bar size: on daily bars a session VWAP collapses to the day's own typical price, so a "close above VWAP" rule has nothing to compare. A rule that goes long when the close is above a moving average and short when it is below has the same shape as a close-above-VWAP rule on intraday bars: one line, two sides, a flip at every cross, and a position almost all the time. That shape, not the line, is what the numbers below show.
The order of steps is the same for the VWAP version and the stand-in:
The run below tested NQ daily bars from 2019-01-02 to 2025-06-30, long and short with one contract, with $20 commission and $10 slippage charged per trade and fills on the next bar. This is the lone survivor of 1,024 tried candidates, kept because its return looked best against its drawdown. Keeping the best of many after the fact flatters the kept one: Bailey, Borwein, López de Prado and Zhu (2014) show that the best result in a large search carries a selection bonus that new data will not repeat. AlphaPrime (Valynox) charges the commission, the slippage and the next-bar fill inside every candidate's evaluation during backtesting, so the ranking that picked this candidate was already net of the costs you see in the box.
Source: AlphaPrime product engine (CPU), run 2026-10-31. NQ daily bars, 2019-01-02 to 2025-06-30, long and short, 1 contract, $20 commission and $10 slippage per trade.
| Number | Result |
|---|---|
| Net profit (closed trades) | $135,480 |
| Max drawdown | $135,820 |
| Trades | 74 |
| Win rate | 60.81% |
| Profit factor | 1.486 |
| Average trade | $1,830.81 |
| Time in market | 91.75% |
Read the box in this order. First, time in market at 91.75 percent confirms the shape: a flip rule holds a position nearly always, so it rides every trend and every reversal. Second, the max drawdown of $135,820 is larger than the net profit of $135,480; a trader following this candidate would at some point have given back more than the whole result, which is the cost of never being flat. Third, the average trade of $1,830.81 is many times the commission and slippage charged per trade, which is what you should expect from 74 trades on daily bars. Move the same rule to intraday bars with a session VWAP and the trade count rises sharply while the average trade shrinks toward the cost; that is the number to compare first, as trading costs in backtests explains. None of these figures is a forecast, and none says what the moving average or VWAP earned; they describe one kept candidate on one history.

If a VWAP version of the rule passes those two checks on your own intraday data, the next step is to run it on a chart with the same session setting. AlphaPrime exports the strategy source code for the supported trading platforms, and the session template on the platform must match the one in the test, or the VWAP line on the chart will not be the one the backtest used.
What to do next: load one week of NQ intraday bars, draw a day-session VWAP and a full-session VWAP on the same chart, and mark every bar where a close is above one line and below the other. The count of those bars tells you how much of a close-above-VWAP rule is the session setting rather than the indicator.
Frequently asked questions
How is the VWAP indicator calculated?
For every bar since the session opened, multiply the bar's typical price (the average of high, low and close) by its volume and add the results together. Divide that total by the total volume of the same bars. The answer is VWAP for the current bar. At the next session open both totals go back to zero and the line starts again from the first bar's typical price.
When does VWAP reset on futures?
VWAP resets at whatever bar the chart or the backtest treats as the session open. On a futures contract that trades through the night, that can be the night open after the daily break or the day-session open, and the two choices draw different lines. Set the session once, use it in both the chart and the backtest, and check the exchange's contract page, because exchanges can change session hours.
What is the difference between VWAP and a moving average?
A moving average averages the closes of a fixed number of recent bars, weights them equally, and never resets. VWAP averages every bar since the session opened, weights each bar by its volume, and resets at the next open. Early in a quiet session the lines can look similar; after a high-volume bar VWAP is pulled toward that bar's price while a moving average barely moves.
Can VWAP be used as an entry and exit signal?
Yes, as a rule such as "long on a close above VWAP, short on a close below", but test it as a rule with costs before trusting it. That rule flips at every cross and is almost always in the market, so the trade count is high on intraday bars and the average trade must be compared with commission and slippage first. The drawdown of a never-flat rule can be as large as its profit, as the NQ run in this article shows for a stand-in rule.
Is a free VWAP indicator on a charting platform enough?
For drawing the line, yes: the formula is the same everywhere, and most charting platforms ship VWAP as a built-in indicator. What you must set yourself is the anchor or session period, because that decides where the sums reset. For a backtest you also need the session, the next-bar fill and the costs written into the test, which the chart's indicator settings do not cover.
References
- Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.
- Brock, W., Lakonishok, J., & LeBaron, B. (1992). Simple Technical Trading Rules and the Stochastic Properties of Stock Returns. The Journal of Finance, 47(5), 1731–1764.
- CME Group. E-mini Nasdaq-100 Futures Contract Specs. https://www.cmegroup.com/markets/equities/nasdaq/e-mini-nasdaq-100.contractSpecs.html

