VALYNOX
VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Indicators and signals

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 · Published · updated · Editorial policy

Contents
  1. What is the VWAP indicator and how is it calculated?
  2. When does VWAP reset on futures, and why do day and night sessions matter?
  3. How does VWAP differ from a moving average?
  4. How do traders use VWAP in trading: trend filter, mean reversion or benchmark?
  5. How do anchored VWAP and VWAP bands change the line?
  6. What does a close-above-VWAP rule look like in a backtest with costs?
  7. Frequently asked questions
  8. 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.

VWAP is a running total: from the session open, five illustrative bars with typical prices 100, 101, 99, 102 and 101 and volumes 200, 400, 100, 300 and 500 give a VWAP of 100.00, 100.67, 100.43, 100.90 and 100.93; both sums reset to zero at the open VWAP is a running total Five bars after the open Illustration Open Reset to zero Price Volume VWAP 100 101 99 102 101 200 400 100 300 500 100.00 100.67 100.43 100.90 100.93 Every bar stays in the sum. So: pick the session open first.
VWAP is a running total, not a rolling window. Every bar since the open stays in the sum until the next session resets it.

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.

  1. Choose the session before you draw anything. Day-only or full-session is a research decision, not a chart cosmetic.
  2. 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.
  3. 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.

Two sessions give two VWAP lines: on one illustrative NQ day the full-session VWAP starts at the night open and the day-session VWAP starts at the day open, and the two lines sit apart in the first hours after the day open; exchanges can change session hours Two sessions, two VWAPs One NQ day, illustrative Price Full session Day session Night open Day open Day close Hours can change: check the exchange. Lines differ after the day open. So: match chart and backtest.
One day of bars, two VWAP lines. The line that resets at the day open ignores the night; the line that resets at the night open carries it.

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.

PropertyMoving averageVWAP
WeightingEqual per bar (or by age for an EMA)By volume of each bar
LookbackLast N barsAll bars since the session start
ResetNeverAt the session open
Value at the first bar of a sessionCarries over from yesterdayEquals the first bar's typical price
After one high-volume barMoves a little, like any barPulled toward that bar's price
Main settingLength NSession start (anchor)
Moving average compared with VWAP: weighting equal versus by volume, lookback last N bars versus since the open, reset never versus at the open, first bar carried over versus its own price, after a heavy bar a small move versus pulled toward it; the reset matters most Moving average vs VWAP Moving average VWAP Weighting Lookback Reset First bar Heavy bar Equal Last N bars Never Carried over Moves a little By volume Since the open At the open Its own price Pulled to it The reset is what matters most. So: set the session first.
The two lines differ in what they weight, how far back they look and whether they reset. The reset is the difference that matters most for a rule.

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.

UseThe rule in one sentenceWhat the test must measure
Trend filterOnly take longs while price is above VWAP, only shorts while belowThe base strategy with and without the filter, same costs, same period; trade count will fall, so compare average trade, not total
Mean reversionFade a stretch away from VWAP and exit when price returns to the lineHow far "a stretch" is (in ticks or bands), how often price never returns before the session ends, and the loss on those trades
Execution benchmarkCompare your average fill with the session VWAPNo strategy test at all; a record of fills versus VWAP over many sessions
One VWAP line, three jobs: as a filter it asks which side price is on, long above and short below; as a fade it asks how far price stretched, entry at the stretch and exit at the touch; as a benchmark it asks what you paid, fills below VWAP better and above worse for a buy One line, three jobs Dashed line: session VWAP Long Short Entry Exit Worse Better Filter Which side? Fade How far? Benchmark Price paid?
Three readings of one line. The filter asks which side you are on, the fade asks how far away you are, the benchmark asks what you paid.

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.

Anchored VWAP keeps running: over three illustrative days the session VWAP restarts each day, while the anchored VWAP starts at a swing low and runs through all three days; bands at multiplier 1 and 2 widen around it without moving the centre line; the inputs are the anchor bar and the multiplier Anchored VWAP keeps running Three days, illustrative Swing low ×2 ×1 Session Anchored Inputs Anchor bar Multiplier ×2 widens bands, not the line. So: write the anchor as a rule.
Session VWAP restarts each day; anchored VWAP runs from the chosen bar. The multiplier only widens the bands, it does not move the centre line.

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:

Six steps of a fair VWAP test in order: set the session, write the rule, fill on the next bar, add costs, compare average trade with cost, then read trade count and time in market; skipping step 1 or 4 tests something different Test in this order Steps of a fair VWAP test 1 2 3 4 5 6 Set session Write rule Next-bar fill Add costs Avg vs cost Trades, time Skip 1 or 4: a different test. So: session and costs first.
Session first, rule second, fills and costs before any number is read. Skipping step 1 tests a different indicator; skipping step 4 tests a different account.

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.

NumberResult
Net profit (closed trades)$135,480
Max drawdown$135,820
Trades74
Win rate60.81%
Profit factor1.486
Average trade$1,830.81
Time in market91.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.

Look at two things: how deep the drawdowns go against the climb of the curve, and whether the marked out-of-sample stretch keeps the shape of the earlier part or changes it.
Look at two things: how deep the drawdowns go against the climb of the curve, and whether the marked out-of-sample stretch keeps the shape of the earlier part or changes it. NQ · daily · 2019-01-02 to 2025-06-30 · CPU engine backtest

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