Indicators··7 min read

Session VWAP with Standard Deviation Bands

0 references, link-verified · inline [n] markersEditor of record: Shane CantyStandards review editorial standard · audit log

Session VWAP displays the volume-weighted average price over a single trading session alongside volatility bands derived from standard deviation. VWAP represents the price level at which the majority of volume has traded during the day; the bands quantify how far current price typically moves from that central level. Day traders, swing traders and market-makers use this to gauge intraday support and resistance, to identify overbought or oversold conditions within a session, and to assess whether price action is normal or exceptional relative to volume distribution.

//@version=6
indicator("Session VWAP with Standard Deviation Bands", overlay=true)

// Inputs
stdDevMult1 = input.float(1.0, title="First Std Dev Multiple", minval=0.1, step=0.1)
stdDevMult2 = input.float(2.0, title="Second Std Dev Multiple", minval=0.1, step=0.1)
showBands = input.bool(true, title="Show Standard Deviation Bands")
showVWAP = input.bool(true, title="Show VWAP Line")

// Session detection: new session starts at bar_index 0 or when time crosses session boundary
isNewSession = barstate.islast ? false : (dayofweek != dayofweek[1] or time < time[1] or barindex == 0)

// Initialize session variables
var float cumVolumePrice = 0.0
var float cumVolume = 0.0
var float sessionVWAP = 0.0

// Reset on new session
if isNewSession
    cumVolumePrice := 0.0
    cumVolume := 0.0
    sessionVWAP := 0.0

// Accumulate volume-weighted price
cumVolumePrice := cumVolumePrice + (hl2 * volume)
cumVolume := cumVolume + volume

// Calculate session VWAP
if cumVolume != 0
    sessionVWAP := cumVolumePrice / cumVolume

// Calculate squared deviations for standard deviation
var float cumSquaredDev = 0.0
if isNewSession
    cumSquaredDev := 0.0

deviation = hl2 - sessionVWAP
cumSquaredDev := cumSquaredDev + (deviation * deviation)

// Calculate standard deviation
barCount = bar_index + 1
variance = cumSquaredDev / barCount
stdDev = math.sqrt(variance)

// Calculate bands
upperBand1 = sessionVWAP + (stdDev * stdDevMult1)
lowerBand1 = sessionVWAP - (stdDev * stdDevMult1)
upperBand2 = sessionVWAP + (stdDev * stdDevMult2)
lowerBand2 = sessionVWAP - (stdDev * stdDevMult2)

// Plotting
plot(showVWAP ? sessionVWAP : na, "Session VWAP", color.rgb(0, 100, 200), linewidth=2)
plot(showBands ? upperBand1 : na, "Upper Band 1σ", color.rgb(150, 180, 220), linewidth=1, linestyle=line.dotted)
plot(showBands ? lowerBand1 : na, "Lower Band 1σ", color.rgb(150, 180, 220), linewidth=1, linestyle=line.dotted)
plot(showBands ? upperBand2 : na, "Upper Band 2σ", color.rgb(100, 130, 180), linewidth=1, linestyle=line.dashed)
plot(showBands ? lowerBand2 : na, "Lower Band 2σ", color.rgb(100, 130, 180), linewidth=1, linestyle=line.dashed)

// Fill between bands for visual clarity
fill(upperBand1, lowerBand1, color=color.new(color.rgb(0, 100, 200), 90), title="1σ Fill")
fill(upperBand2, lowerBand2, color=color.new(color.rgb(0, 100, 200), 95), title="2σ Fill")

How the code works

The indicator runs cumulative calculations throughout the trading session. On the first bar of a new session (detected by checking if the day of week changes or the bar is the very first bar), it resets all accumulators to zero. For each subsequent bar, it adds the product of mid-price (hl2: average of high and low) and volume to a running sum, then divides the cumulative volume-weighted sum by cumulative volume to obtain the session VWAP. This is exact, not an approximation.

To compute standard deviation, the code calculates the squared deviation of each bar's mid-price from VWAP, accumulates these squared deviations, and divides by the bar count within the session to compute variance. The standard deviation is the square root of variance. The bands are plotted at VWAP plus or minus one, two, or more multiples of standard deviation, allowing the trader to set the sensitivity via the "Std Dev Multiple" inputs.

The code uses the var keyword to preserve values across bars within a session, resetting them when a new session is detected. No future data is referenced; all calculations use only the current and prior bars.

Reading it on a chart

On an intraday chart, the blue line marks session VWAP. The dotted lines 1 standard deviation above and below VWAP show where approximately 68% of price action typically clusters (under normal conditions); the dashed lines 2 standard deviations out contain roughly 95%. When price remains close to VWAP, it signals participation near the session average. A spike beyond the 2σ band is statistically rare and may signal exhaustion, a reversal, or a significant event. A wide band indicates high intraday volatility; a narrow band suggests price is tightly distributed and liquidity is well-matched. At session open, the bands start narrow and widen as the day progresses and more bars accumulate data.

Traders often use these bands to identify mean-reversion setups (price touches a band and snaps back to VWAP) or breakout confirmation (price sustains beyond a band, suggesting momentum). The visual fill between bands helps quickly assess the range in which most volume traded.

Limitations

This indicator is sensitive to session boundary definition. In global markets where sessions overlap or where multiple trading sessions coexist (e.g., stock pre-market, regular market, after-hours), the indicator treats them as a single session unless manually configured for a specific session type; users must ensure the chart is set to the correct timeframe and session to obtain accurate results. The standard deviation calculation assumes that price movements follow a normal distribution, which real market data violates during gaps, liquidity shocks, or news announcements; the bands may provide false confidence in extreme conditions.

VWAP itself does not predict price movement; it is descriptive only. Price is not "attracted" to VWAP mechanically. Many traders and algorithms reference VWAP, which can create self-reinforcing movement around it, but no guarantee of mean reversion exists. The indicator produces no trade signals and offers no edge without additional context; it is a reference tool, not a complete system.

Bands widen monotonically as the session progresses (because more bars accumulate, widening the standard deviation envelope), which can obscure the difference between "price is volatile" and "time has simply elapsed." The historical standard deviation does not forecast future intraday volatility. On very low-volume bars or illiquid assets, VWAP can be distorted by a single large trade. The indicator resets at session close and does not carry forward multi-day profiles.

Key definitions

VWAP (Volume Weighted Average Price): the cumulative sum of price multiplied by volume, divided by cumulative volume over a defined period, representing the average price weighted by participation at each level.

Standard Deviation: a measure of dispersion around a mean; calculated as the square root of the average of squared deviations from the mean, expressing how far typical values stray from the center.

Standard Deviation Band: an upper or lower boundary at a fixed multiple of standard deviation above or below a central line (here, VWAP), used to quantify normal vs. exceptional price range.

Session: a discrete trading period, typically a calendar day in equity markets or a 24-hour or regional day in futures; the indicator resets calculations at session boundaries.

Mid-price: the average of the high and low price for a bar, used here as a representative price when open and close are not specified.

References


Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard.

Last reviewed by the PropLedger research pipeline: 2026-09-13. Educational research on historical data, not financial advice.

Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard. Found an error? Email support@prop-ledger.org and the paper is corrected or withdrawn.