Indicator comparison

VWAP vs VWMA: session resets vs rolling windows

VWAP accumulates price and volume from a reset. VWMA uses only the latest N bars. At a new session, VWAP can discard yesterday while VWMA still includes it.

Direct answer

Choose session VWAP when the question starts at a session boundary. Choose VWMA when the question concerns a fixed number of recent bars, including bars before the current session. Both divide summed price-volume by summed volume. Hold the price source, chart session, interval, and confirmation time constant before attributing a difference to the indicator.

What to set before testing

VWAP window

Since the selected reset

VWMA window

Latest N chart bars

Worked example

7 synthetic bars, VWMA length 3

Script comparison

Same source, confirmed bars only

One price-volume series, two windows

Synthetic prices in dollars and volumes in shares; no market-performance claim. Each row is one completed chart bar. Day 1 begins at an observed reset. Day 2 follows an overnight gap with no intervening chart bars. VWMA requires all 3 bars before displaying a value. Results are rounded to 4 decimals.

Bar: price × volumeSession VWAP ($)3-bar VWMA ($)
Day 1, bar 1: 100 × 10100.0000Not ready
Day 1, bar 2: 102 × 20101.3333Not ready
Day 1, bar 3: 104 × 10102.0000102.0000
Day 1, bar 4: 106 × 10102.8000103.5000
Day 2, bar 1: 110 × 10110.0000106.6667
Day 2, bar 2: 108 × 30108.5000108.0000
Day 2, bar 3: 112 × 10109.2000109.2000

A test workflow you can audit

  1. 1

    Fix the data before comparing lines

    Use standard time-based intraday candles, one symbol and interval, and the same regular or extended-hours setting. Set both sources to HLC3 or both to close. Comparing default sources without checking them can mix two different experiments.

  2. 2

    Inspect the actual reset bar

    The script marks each observed new daily period. Check its timestamp against the intended session open. It does not hardcode 09:30 or your local midnight; daily boundaries depend on the instrument and chart session.

  3. 3

    Read both values at the same close

    Wait for the bar to close, then inspect Daily VWAP, Rolling VWMA, and their difference in the Data Window. The script suppresses both plots on an unfinished realtime bar.

  4. 4

    Separate the line comparison from a trade test

    If you later test entries, keep the close-confirmed decision rule, fill model, fees, exits, and sample dates fixed. A line difference alone says nothing about returns. Reserve later dates before choosing a lookback.

Checks to make on your chart

These checks keep the rule separate from the story told after a move has already happened.

Twenty 5-minute chart bars contain 100 minutes of bar duration, but can span an overnight or weekend gap. A bar-count lookback is not a fixed elapsed-time window.

An old high-volume bar leaving VWMA can move the line even when the new price barely changes. Session VWAP retains that bar until its reset.

HLC3 times bar volume is a bar-level approximation. Changing the chart interval can change that approximation even when the same session is visible.

Adapt the comparison in Pineify

Pine Script AI Coding Agent can generate and edit inspectable Pine code and run a syntax check. Give it the chosen reset and missing-data policy, then verify the generated behavior on TradingView. A successful syntax check does not establish a trading edge.

Adapt this VWAP versus VWMA comparison in Pine Script v6. Keep one shared source, chart volume, and confirmed-bar output. Preserve the rolling window across daily boundaries. Expose the VWMA length, document the reset rule, and suppress a window that includes missing or negative volume. Run the syntax checker, explain the first loaded session behavior, and list chart checks for overnight gaps and zero volume. Do not add trades or claim profitability.
Turn the rule into inspectable Pine Script

Recalculate the opening gap

For price p and volume v, VWAP = sum(p × v since reset) / sum(v since reset). VWMA(N) = sum(p × v over the latest N bars) / sum(v over those N bars). The difference is the set of included bars.

At Day 1 bar 4, VWAP = (1,000 + 2,040 + 1,040 + 1,060) / 50 = 102.8. VWMA drops bar 1, so it becomes (2,040 + 1,040 + 1,060) / 40 = 103.5.

At the Day 2 open, VWAP = 1,100 / 10 = 110. The rolling window still contains Day 1 bars 3 and 4: VWMA = (1,040 + 1,060 + 1,100) / 30 = 106.6667. By Day 2 bar 3, both include exactly the same three bars and equal 5,460 / 50 = 109.2. They need not remain equal on the next bar.

What changes at the open and overnight

With positive volume on the first bar after a reset, VWAP equals that bar's selected price source. That is HLC3 when HLC3 is selected, not necessarily the opening trade or closing price. VWMA can already be ready because its previous bars remain in the window.

If extended-hours bars are included, they enter the rolling window and may also enter the cumulative period. If they are excluded, the window jumps directly from the last available bar to the next open. Neither calculation invents bars for the gap.

An overnight futures session can begin on the preceding calendar date. Treat the daily reset used below as an explicit research choice. A custom regular-hours-only VWAP requires both a session filter and its own reset logic; changing the chart display timezone does not implement that rule.

Pine Script: compare completed bars

Paste this indicator into TradingView Pine Editor on an intraday time-based chart. It uses the chart's daily-period changes for VWAP and N chart bars for VWMA. The source defaults to HLC3 for both. Select length 3 to match the worked example's window size, or another length for your own data.

The first loaded daily period is deliberately omitted from VWAP because chart history might start midway through it. Accumulation begins at the next observed daily boundary. VWMA begins after N loaded bars. Both plots and the Data Window difference are published only at bar close; this indicator places no orders.

Pine Script v6. Syntax checked on October 18, 2026. The explicit sums define the missing-data policy below; chart behavior and any future trade rule still require separate verification.pine
//@version=6
indicator("VWAP vs VWMA: matched data", overlay = true)
source = input.source(hlc3, "Shared price source")
length = input.int(3, "VWMA bars", minval = 1, maxval = 500)
if not timeframe.isintraday
    runtime.error("Use an intraday time-based chart.")
// Daily boundaries follow the symbol and chart session, not local midnight.
newDay = timeframe.change("1D") and not barstate.isfirst
valid = not na(source) and not na(volume) and volume >= 0
pv = valid ? source * volume : 0.0
weight = valid ? volume : 0.0
var bool started = false
var bool invalidDay = false
var float dayPV = 0.0
var float dayVolume = 0.0
if newDay
    started := true
    invalidDay := false
    dayPV := 0.0
    dayVolume := 0.0
if started
    invalidDay := invalidDay or not valid
    dayPV += pv
    dayVolume += weight
sessionVwap = started and not invalidDay and dayVolume > 0 ? dayPV / dayVolume : na
windowPV = math.sum(pv, length)
windowVolume = math.sum(weight, length)
invalidBars = math.sum(valid ? 0.0 : 1.0, length)
rollingVwma = bar_index >= length - 1 and invalidBars == 0 and windowVolume > 0 ? windowPV / windowVolume : na
// Both outputs use the same completed bar. No orders or intrabar signals.
confirmed = barstate.isconfirmed
plot(confirmed ? sessionVwap : na, "Daily VWAP", color.blue, 2, plot.style_linebr)
plot(confirmed ? rollingVwma : na, "Rolling VWMA", color.orange, 2, plot.style_linebr)
plot(confirmed ? sessionVwap - rollingVwma : na, "VWAP minus VWMA", display = display.data_window)
plotshape(newDay and confirmed, "Daily reset", shape.circle, location.bottom, color.gray, size = size.tiny)

Zero volume and missing data are different cases

A zero-volume bar contributes zero weight but still occupies one VWMA slot. If it replaces an older bar, VWMA can change; cumulative VWAP stays unchanged unless it resets. A window whose total volume is zero has no weighted mean and returns na.

The script treats a missing price, missing volume, or negative volume as invalid. VWMA stays unavailable until that bar leaves its N-bar window. VWAP stays unavailable until the next daily reset. This strict policy avoids silently treating unknown volume as known zero volume.

A chart bar that is absent entirely cannot be detected by these checks. Confirm data coverage and the meaning of volume for the selected feed. Tick volume and exchange trade volume measure different things, so results from different feeds are not automatically comparable.

Choose the memory your rule needs

Use session VWAP for a question such as price relative to the current session's volume-weighted bar prices. Use VWMA for a question about the latest N bars regardless of session boundaries. A daily VWAP on a daily chart has only one bar per reset, so the script requires an intraday chart.

Neither line is universally faster or better. A late-session VWAP often retains more history than a short VWMA, while a new-session VWAP can react immediately as a longer VWMA retains yesterday. Evaluate the written rule on the intended data rather than choosing whichever line fits a past move.

Sources

  • Volume Weighted Average Price (VWAP)

    TradingView Help Center. Documents the VWAP formula, anchor periods, source input, bands, and timeframe behavior. Checked October 18, 2026.

  • Volume-Weighted Moving Average (VWMA)

    TradingView Help Center. Documents the rolling VWMA calculation and its use as a volume-weighted moving average. Checked October 18, 2026.

  • Sessions

    TradingView Pine Script documentation. Defines chart sessions, overnight sessions, and session time zones. Checked October 18, 2026.

  • Time

    TradingView Pine Script documentation. Documents daily-period changes and the distinction between exchange and chart time zones. Checked October 18, 2026.

  • Bar states

    TradingView Pine Script documentation. Defines barstate.isconfirmed on historical bars and closing realtime updates. Checked October 18, 2026.

Frequently asked questions

This page is an educational information tool, not investment advice or a recommendation to trade. Examples are test definitions, not live signals, historical results, or promises of returns. VWAP is based on past price and volume, and actual fills can differ from chart prices. Check current market data, costs, product rules, and your own risk limits before trading.

Put the VWAP rule in writing

Pineify turns a plain-language setup into Pine Script you can read, edit, and test. The script does not predict the next price.

Build a VWAP test rule