VWAP with Bands
Session volume-weighted average price with up to three pairs of volume-weighted standard deviation bands.
- VWAP Bands
- Built into Spectral
- Updates every tick
- Uses volume
- vwap
- vwap bands
- standard deviation
- intraday
- session
- mean reversion
MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.
Already in Spectral: add it from the Indicators toolbox. The file here is the same indicator written as a custom indicator, to change or learn from. Installed, it appears next to the built-in one, marked Custom.

Overview
VWAP is the volume-weighted average price of the trading session: every price is weighted by the volume traded at it, so it shows the average price actually paid. It restarts at the beginning of each New York trading date. This indicator adds up to three pairs of bands at a chosen number of standard deviations above and below VWAP.
The deviation is volume-weighted: the square root of (sum of volume times price squared / sum of volume - VWAP squared), evaluated cumulatively from the session start, so the bands start narrow and widen as the day unfolds.
How to read it
VWAP acts as the fair price of the day. Price above it means buyers have been paying up through the session; price below it, the opposite. Institutions often judge execution against VWAP, which is why price tends to react around it.
The bands show how far price has stretched from the day's average, in standard deviations. Price at the first band is a normal excursion; at the second or third band it is stretched, and moves often pause or revert toward VWAP, but a strong trend day can walk along the outer bands. Bands are narrow early in the session and unreliable for the first few bars.
Settings and limitations
Source is the price that is weighted by volume (hlc3 by default; close is a common alternative). Band 1, 2 and 3 switch each pair on or off, and the multipliers set their distance in standard deviations (1, 2 and 3 by default). Shaded zones fills between each enabled pair and can be switched off; zone colors and opacity are in the style settings.
VWAP appears on the first bar of a session that has volume and restarts at each New York trading date, so on daily and longer bar sizes it is just the bar's own price. It suits intraday bar sizes.
Notes
The calculation is the standard session VWAP with volume-weighted standard deviation bands, the same definition TradingView uses for its VWAP indicator (default bands there are at 1 standard deviation, here 1, 2 and 3 are available). The difference is the session: TradingView restarts VWAP at the exchange session start, while Spectral restarts it at the New York calendar date, so for instruments that trade around the clock, such as futures, the restart is at midnight New York time. Bars with no volume do not move VWAP. Extended-hours bars are included when the chart loads them.
Settings
Each setting appears in the indicator's settings panel in Spectral, next to a color setting for every output.
| Setting | Type | Default | Range or options | What it does |
|---|---|---|---|---|
| Source | Price source | hlc3 | open, high, low, close, hlc3 | Price weighted by volume. hlc3 is the average of high, low and close. |
| Band 1 | On / off | On | — | Draw the first pair of bands. |
| Band 1 multiplier | Number | 1 | 0.1 – 10, step 0.1 | Distance of the first bands from VWAP, in standard deviations. |
| Band 2 | On / off | On | — | Draw the second pair of bands. |
| Band 2 multiplier | Number | 2 | 0.1 – 10, step 0.1 | Distance of the second bands from VWAP, in standard deviations. |
| Band 3 | On / off | On | — | Draw the third pair of bands. |
| Band 3 multiplier | Number | 3 | 0.1 – 10, step 0.1 | Distance of the third bands from VWAP, in standard deviations. |
| Shaded zones | On / off | On | — | Fill the area between each pair of enabled bands with a light color. |
Presets
Each preset is its own entry in the Indicators toolbox, with these settings changed.
| Toolbox entry | Short name | Settings |
|---|---|---|
| VWAP with Bands (1, 2) | VWAP 1-2 | Band 1: trueBand 2: trueBand 3: false |
| VWAP with Band (1) | VWAP 1 | Band 1: trueBand 2: falseBand 3: false |
| VWAP with Bands (close) | VWAP close | Source: close |
What it draws
Lines
- VWAPsolid · 1.5 px · primary
#D4A85F - Upper band 1solid · 1 px
#8AA9C3 - Lower band 1solid · 1 px
#8AA9C3 - Upper band 2dashed · 1 px
#8AA9C3 - Lower band 2dashed · 1 px
#8AA9C3 - Upper band 3dotted · 1 px
#8AA9C3 - Lower band 3dotted · 1 px
#8AA9C3
Zones
- Zone 1filled at 7% opacity
#8AA9C3 - Zone 2filled at 5% opacity
#8AA9C3 - Zone 3filled at 3% opacity
#8AA9C3
Source
Save it as vwap-bands.js and add it with Indicators → Custom indicators → Add file…. The format is explained in the custom indicators guide.
// Copyright (c) 2026 Spectral
// SPDX-License-Identifier: MIT-0
// Free to use, copy, modify and share: https://spectral.trade/docs/custom-indicators/LICENSE.txt
/** @type {import('./spectral-indicator').IndicatorV2} */
export default {
schemaVersion: 2,
id: 'vwap-bands',
name: 'VWAP with Bands',
shortName: 'VWAP Bands',
version: '1.0.0',
author: 'Spectral',
description: 'Session volume-weighted average price with up to three pairs of volume-weighted standard deviation bands.',
pane: 'price',
live: { lookback: 0 },
usesVolume: true,
inputs: {
source: { type: 'source', label: 'Source', default: 'hlc3', description: 'Price weighted by volume. hlc3 is the average of high, low and close.' },
showBand1: { type: 'boolean', label: 'Band 1', default: true, description: 'Draw the first pair of bands.' },
mult1: { type: 'number', label: 'Band 1 multiplier', default: 1, min: 0.1, max: 10, step: 0.1, description: 'Distance of the first bands from VWAP, in standard deviations.' },
showBand2: { type: 'boolean', label: 'Band 2', default: true, description: 'Draw the second pair of bands.' },
mult2: { type: 'number', label: 'Band 2 multiplier', default: 2, min: 0.1, max: 10, step: 0.1, description: 'Distance of the second bands from VWAP, in standard deviations.' },
showBand3: { type: 'boolean', label: 'Band 3', default: true, description: 'Draw the third pair of bands.' },
mult3: { type: 'number', label: 'Band 3 multiplier', default: 3, min: 0.1, max: 10, step: 0.1, description: 'Distance of the third bands from VWAP, in standard deviations.' },
showZones: { type: 'boolean', label: 'Shaded zones', default: true, description: 'Fill the area between each pair of enabled bands with a light color.' },
},
plots: {
vwap: { label: 'VWAP', color: '#D4A85F', lineWidth: 1.5, primary: true },
upper1: { label: 'Upper band 1', color: '#8AA9C3' },
lower1: { label: 'Lower band 1', color: '#8AA9C3' },
upper2: { label: 'Upper band 2', color: '#8AA9C3', lineStyle: 'dashed' },
lower2: { label: 'Lower band 2', color: '#8AA9C3', lineStyle: 'dashed' },
upper3: { label: 'Upper band 3', color: '#8AA9C3', lineStyle: 'dotted' },
lower3: { label: 'Lower band 3', color: '#8AA9C3', lineStyle: 'dotted' },
},
zones: {
zone1: { label: 'Zone 1', color: '#8AA9C3', opacity: 0.07 },
zone2: { label: 'Zone 2', color: '#8AA9C3', opacity: 0.05 },
zone3: { label: 'Zone 3', color: '#8AA9C3', opacity: 0.03 },
},
presets: [
{ id: 'bands-1-2', name: 'VWAP with Bands (1, 2)', shortName: 'VWAP 1-2', inputs: { showBand1: true, showBand2: true, showBand3: false } },
{ id: 'band-1', name: 'VWAP with Band (1)', shortName: 'VWAP 1', inputs: { showBand1: true, showBand2: false, showBand3: false } },
{ id: 'close', name: 'VWAP with Bands (close)', shortName: 'VWAP close', inputs: { source: 'close' } },
],
docs: {
overview: 'VWAP is the volume-weighted average price of the trading session: every price is weighted by the volume traded at it, so it shows the average price actually paid. It restarts at the beginning of each New York trading date. This indicator adds up to three pairs of bands at a chosen number of standard deviations above and below VWAP.\n\nThe deviation is volume-weighted: the square root of (sum of volume times price squared / sum of volume - VWAP squared), evaluated cumulatively from the session start, so the bands start narrow and widen as the day unfolds.',
howToRead: 'VWAP acts as the fair price of the day. Price above it means buyers have been paying up through the session; price below it, the opposite. Institutions often judge execution against VWAP, which is why price tends to react around it.\n\nThe bands show how far price has stretched from the day\'s average, in standard deviations. Price at the first band is a normal excursion; at the second or third band it is stretched, and moves often pause or revert toward VWAP, but a strong trend day can walk along the outer bands. Bands are narrow early in the session and unreliable for the first few bars.',
settings: 'Source is the price that is weighted by volume (hlc3 by default; close is a common alternative). Band 1, 2 and 3 switch each pair on or off, and the multipliers set their distance in standard deviations (1, 2 and 3 by default). Shaded zones fills between each enabled pair and can be switched off; zone colors and opacity are in the style settings.\n\nVWAP appears on the first bar of a session that has volume and restarts at each New York trading date, so on daily and longer bar sizes it is just the bar\'s own price. It suits intraday bar sizes.',
notes: 'The calculation is the standard session VWAP with volume-weighted standard deviation bands, the same definition TradingView uses for its VWAP indicator (default bands there are at 1 standard deviation, here 1, 2 and 3 are available). The difference is the session: TradingView restarts VWAP at the exchange session start, while Spectral restarts it at the New York calendar date, so for instruments that trade around the clock, such as futures, the restart is at midnight New York time. Bars with no volume do not move VWAP. Extended-hours bars are included when the chart loads them.',
},
calculate(ctx) {
const { bars, inputs, ta, time } = ctx;
const count = bars.length;
const price = ta.source(bars, inputs.source);
const items = bars.map((bar, index) => ({ bar, price: price[index] }));
// The session's weight, mean and spread carry from bar to bar through ta.scan; a new New York date resets them.
const states = ta.scan(items, { weight: 0, mean: 0, spread: 0, date: '' }, (state, item) => {
const date = time.ny(item.bar).dateKey;
let { weight, mean, spread } = date === state.date ? state : { weight: 0, mean: 0, spread: 0 };
const volume = Number(item.bar.volume);
if (Number.isFinite(volume) && volume > 0) {
// Weighted incremental mean and variance: stable and identical to sum(v*p)/sum(v) and sum(v*p*p)/sum(v) - vwap*vwap.
weight += volume;
const delta = item.price - mean;
mean += (volume / weight) * delta;
spread += volume * delta * (item.price - mean);
}
return { weight, mean, spread, date };
});
const vwap = states.map((state) => (state.weight > 0 ? state.mean : null));
const deviation = states.map((state) => (state.weight > 0 ? Math.sqrt(Math.max(0, state.spread / state.weight)) : null));
const plots = { vwap };
const zones = {};
const shown = [inputs.showBand1, inputs.showBand2, inputs.showBand3];
const multipliers = [inputs.mult1, inputs.mult2, inputs.mult3];
for (let band = 0; band < 3; band += 1) {
const upper = shown[band] ? offsetSeries(vwap, deviation, multipliers[band]) : new Array(count).fill(null);
const lower = shown[band] ? offsetSeries(vwap, deviation, -multipliers[band]) : new Array(count).fill(null);
plots['upper' + (band + 1)] = upper;
plots['lower' + (band + 1)] = lower;
if (shown[band] && inputs.showZones) zones['zone' + (band + 1)] = { upper, lower };
}
return { plots, zones };
},
};
function offsetSeries(center, deviation, multiplier) {
return center.map((value, index) => (value === null || deviation[index] === null ? null : value + multiplier * deviation[index]));
}Adapt it with an LLM
Paste this into your assistant and replace the second-to-last line with the change you want.
Start from this Spectral custom indicator: https://spectral.trade/indicators/vwap-bands.js Format reference: https://spectral.trade/docs/custom-indicators.llm.md Keep the file format and every rule of the reference; give the result a new id, name, shortName and version, and update docs and input descriptions to match. Keep its live updates exact and fast (section "Fast live updates" of the reference): carry values from bar to bar only through ctx.ta, and raise live.lookback if the change reads further back; Spectral rejects a file whose live updates differ from a full recalculation or are too slow. Change I want: <describe the change> Answer with the complete file in one code block, ready to save as <id>.js.


