VWAP

Volume-weighted average price since an anchor: a day, week, month or session start, a time, or a recent high or low.

Anchored VWAP = Σ(x × volume) ÷ Σ volume since the anchor; x defaults to hlc3. anchor: the start of the current UTC day, ISO week (Monday) or calendar month; time = from anchor_time (UTC); highest_high / lowest_low = from the candle with the highest high / lowest low of the last anchor_length candles (the latest on a tie; the anchor moves when a new extreme comes or the old one leaves the window); session = from each local start of anchor_session (a configured session's start, or time zone|HH:MM with optional |mon,tue,… days), restarting on the first candle that opens at or after it, no value before the first start seen. Bands: upper / lower = VWAP ± mult × σ, σ = √(Σ(volume × x²) ÷ Σ volume − VWAP²). Ready only once the series has seen its anchor (a period or time anchor: the first candle opens at it or the series started before it; a high / low anchor: anchor_length candles seen), so a value never covers part of its span; not ready while the volume is 0. The time and high / low anchors load anchor_length candles before the start (the plan's lookback cap applies); the time must fall inside them. Mirror: price.

Settings

SettingDefaultRangeWhat it does
anchordayday, week, month, time, highest_high, lowest_low, sessionWhere the sums start: a period start, a time, or the latest high / low.
anchor_time2024-01-01T00:00With anchor time: the UTC time the sums start at (YYYY-MM-DDTHH:MM).
anchor_length202 to 5000With a high / low anchor: the candles searched for the high or low; with time: the candles loaded before the start.
mult10 to 10Band width in standard deviations.
anchor_sessionnoneWith anchor session: the session whose local start restarts the sums (a configured session, or time zone|HH:MM, e.g. America/New_York|09:30).

What it gives

OutputWhat it is
VWAPVolume-weighted average price since the anchor.
Upper bandVWAP + mult × σ.
Lower bandVWAP − mult × σ.

What it reads

It reads open, high, low, close, hl2, hlc3, ohlc4, hlcc4, hlc3 by default.

Warm-up

With its default settings, VWAP needs 1 closed candles before its first value. A backtest loads them before its start date, so the first trade can already use it.

Test it

Copy this sentence into the Algonney chat to backtest it:

Backtest a strategy on BTC that uses VWAP with its default settings