# VWAP deviation bands (mean reversion) on gold (XAUUSD), 5-minute bars, London and New York sessions - specification (RIP Backtest protocol v1.0 plus the 8 Oct 2026 rules)

Specification written and **frozen 2026-11-02 (approved by the owner the same day, draft 1 unchanged: "ok fa cum zici tu si ingheata")**. No VWAP, band, signal or trade of this test has been computed on gold. (A data check only was run before this draft: the tick volume and the number of complete sessions per year, below.) Once frozen, any change of a rule is documented and treated as a separate test; bugs may be fixed.

## Why this test, where the rules come from, and what was looked at before
- **Proposed by the owner** on 2026-11-02, in a text pasted into the conversation (not from a named video or author), and tightened the same day. Where the proposal left a choice open, it is fixed here and marked as ours.
- **The idea:** when gold closes far from its session VWAP, bet on the return to the VWAP.
- **This is a replication, chosen knowing the earlier result.** The same rule has been tested on ES: the VW-BANDS version of our VWAP test (`vw_spec.md`, 5-minute bars, New York session) made 7,803 trades, -$42.51 a trade after costs (-$11.75 before), 22.4% winners, 75% of trades stopped, at the 0.0th percentile of its control, 1 gate of 6, buried. Our cross-market scoreboard found that a result on one market says little about another, so the question is still open on gold; but this selection is stated wherever the test is reported, and it is one reason for the strict t bar.
- **What is the same as on ES:** the VWAP and band formulas, 5-minute bars, the signal zone between 2 and 3 standard deviations, the fixed stop just beyond the 3 SD line, the exit after a close back at the VWAP, no signal in the session's first 30 minutes or on its last bar. **What differs (ours, stated):** two sessions instead of one; tick volume instead of contract volume; at most one trade per direction per session (from the proposal; ES had no such limit); the gates in R.
- **Dropped from the proposal:** the 1.5 SD bands (no rule used them). A close beyond the 3 SD line is not a signal (the proposal would have entered past its own stop).
- **Looked at before on this gold file (disclosed):** 17 strategies in 109 versions (the gold hub), among them the **noise area breakout on the same two sessions** (it computes the session VWAP from tick volume for its trailing stop; buried), **RSI 30/70 on 5-minute bars** (all lost), the **H1 Open Trap** (a median stop of $1.37; costs about 0.29 R a trade), the 5-minute trend pullback and the previous-day high and low reversal (all buried); and, unpublished, a 5-minute sweep model (buried). On EUR/USD, the anchored VWAP (buried by costs). **No VWAP band has been computed on gold.** The results are exploratory: the holdout years have been used before and cannot confirm anything independently.

## Instrument and data
- **XAUUSD** spot, IC Markets MT4 demo, 1-minute **bid** bars, 2004-06-11 to **2026-10-07 16:57 New York**, stamped at their close. **Volume = MT4 tick volume** (byte 40 of each record, `na_lib.loadHst`), a proxy: spot gold has no contract volume. No historical spread is available; costs are a fixed amount.
- **Clock:** the sessions depend on the time of day, so the run uses **the clock of our clock audit** (`gold_audit_clock.loadAuditClock`), which moves the weeks found an hour early, most of them in 2004-2010; the noise area test on these sessions used the same correction. The whole run is repeated on `gx_lib.loadGold({ fix: true })` and on the uncorrected file, and the differences reported; the verdict is that of the audit clock.
- **Sessions (each its own variant; real local time, with the daylight-saving rules of each city):** **London** 08:00 to 16:30 London time; **New York** 09:30 to 16:00 New York time. Monday to Friday. They overlap (usually 09:30 to 11:30 New York); each has its own VWAP and its own position.
- **A session is used** only if the minute stamped one minute after its open exists and at least **80% of its minutes** exist. Missing minutes are never filled.
- **Data check, audit clock (median tick volume per minute; sessions kept of the weekdays in the year):**

| Year | Median ticks | London kept | New York kept |
|---|---|---|---|
| 2004 (from 11 June) | 1 | 3 of 146 | 21 of 146 |
| 2005 | 1 | 0 of 260 | 3 of 260 |
| 2006 | 2 | 6 of 260 | 33 of 260 |
| 2007 | 4 | 136 of 261 | 196 of 261 |
| 2008 | 6 | 247 of 262 | 251 of 262 |
| 2009 to 2025 | 21 to 78 | 239 to 259 a year | 234 to 251 a year |
| 2026 (to 7 Oct) | 353 | 198 of 200 | 192 of 200 |

  No minute has zero volume. **In practice the test starts in 2007**, and until about 2008 the tick counts are so low that the VWAP is close to a plain average of prices. The jump in 2026 shows that the broker's tick count is not comparable across years; only the weights inside a session matter, so the VWAP is usable, but this is stated.
- **Bars:** 5-minute bars of the session's minutes, closing 5, 10, 15 ... minutes after its open; built from the minutes that exist; a bar with no minute does not exist.
- **Holes (rule 3):** a trade is dropped if there is a gap of more than 30 minutes between consecutive minutes from its session's open to its exit (the threshold of `data_holes_xau.json`, recomputed on the clock in use, because that file is on another clock), and every gate and verdict is recomputed without those trades.

## The session VWAP and its bands (as on ES)
- **Typical price** of a 5-minute bar: (high + low + close) / 3. **Volume:** the sum of its minutes' tick volume.
- **VWAP** at the close of bar k: the sum of typical price x volume over the session's bars up to k, divided by their volume. It restarts every session.
- **Standard deviation** at bar k: sqrt(sum(volume x typical price squared) / sum(volume) - VWAP squared). **Bands:** VWAP +/- 2 and 3 SD.

## Rules (for a long; a short is the mirror image)
- **Signals** are read at the close of each 5-minute bar, from the bar closing 30 minutes after the session's open (with few bars the deviation means nothing), and not on the session's last bar.
- **Long signal:** the bar closes at or below VWAP - 2 SD and at or above VWAP - 3 SD.
- **Entry:** at the open of the first minute after the signal bar.
- **Stop:** $0.01 below the VWAP - 3 SD line of the signal bar, **fixed**. If the entry is at or below the stop: no trade, and the direction stays available. **R** = entry to stop. There is **no minimum stop** (the proposal has none; a sensitivity is reported below).
- **Target, the VWAP:** the position is closed at the open of the first minute after the first 5-minute bar that closes at or above **the then current VWAP** (the VWAP moves, so this is not a resting order).
- **Stop check:** on every minute from the entry minute on; a minute opening beyond the stop exits at its open.
- **Session close:** a position still open closes at the close of the session's last minute. Nothing is held overnight, so there is no swap.
- **Frequency:** one position at a time per variant; **at most one trade per direction per session**; a signal while a position is open is ignored and does not use up its direction.

## Variants (the only ones tested)
**GVB-LD** (London session) and **GVB-NY** (New York session), both long and short. Each is reported on its own; neither is chosen after the results.

## Costs
**$0.30 per ounce per round trip**, as in every gold test on the site; also shown at **1.5x ($0.45)** and **2.5x ($0.75)**. The verdict is that of the base cost.

## Periods, gates, control
- **Unit: net R per trade** for the gates (our choice: gold rose from about $400 to over $4,000, so dollar totals weigh the recent years far more). Results are also reported in dollars per ounce. With no minimum stop, very small stops can weigh on the R average, so the stop sizes are reported.
- **Periods (by trade date), as in every gold test:** development 2004 to 2012 (in practice 2007 to 2012); validation 2013 to 2019; holdout 2020 to 2026-10-07 (**already used** by many gold tests; reported, not presented as independent confirmation).
- **Six gates per variant:** validation profit factor >= 1.2; at least 50 trades in each period; development **t >= 2.5** (chosen after a known result on ES; many strategies tried on this file); above the 95th percentile of 500 runs of the matched control; positive without the 10 best trades; holdout net positive (flagged used). Fewer than 30 trades in all: Inconclusive.
- **Matched control (moved trades):** every real trade moved, all together, by one random circular offset of whole usable sessions of its variant (at least 5% of them), entered at the open of the first minute at or after the same time after the session's open, same direction. **The stop is scaled:** the same number of standard deviations from the entry as the real trade, using the moved session's SD at its last closed bar (ours: a stop fixed in dollars would not be comparable after gold's rise). The same exits on the moved session's own VWAP, the same session close and costs. 500 runs, seeds 1000 + run. Statistic: average net R per trade.

## Also reported (descriptive: no gates, no verdict)
How often a bar closes in the signal zone and beyond the 3 SD line; exits by reason; win rate with its Wilson interval; long and short separately; the median stop in dollars and the cost in R; results by stop size (under $1, $1 to $2, $2 to $5, over $5); by year, with 2004-2007 shown separately; by hour of entry; the cost scenarios; **trend and consolidation sessions** (trend = the session's open-to-close move is at least half of its high-to-low range; known only when the session ends, so it cannot be a trading filter); the comparison with VW-BANDS on ES; the runs on the two other clocks.

## Engine and self-test (before the run)
New engine `gvb_lib.js`, independent re-implementation `gvb_ref.js`, `gvb_selftest.js` that must pass before any result is printed: the VWAP and SD against hand-worked values, and their restart each session; both sessions in a normal week and in daylight-saving mismatch weeks; a session under 80% coverage (skipped); a bar with no minute; no signal before 30 minutes or on the last bar; a close in the zone, outside it, and beyond 3 SD (no signal); the entry at the next minute's open; an entry at or beyond the stop; the fixed stop (also in the entry minute, and gapped through); the exit after a close back at the moved VWAP; the session close; one trade per direction per session; a signal ignored while in a position; a short; the hole rule; the reference matched trade by trade on the real data for both variants, on all three clocks; the control machinery at offset 0, without the stop scaling (the real stop distance); and a mutation check, in which deliberate changes to the rules must make the test fail.

## Forward test
Only if the historical result justifies it, under a separate protocol frozen before its first day. Not started by this specification.

## Before the article
Results go to the owner first: both variants, every gate, long and short, by year, the exits, the cost in R, the stop sizes, the other clocks. One article, published only with the owner's agreement, linked to the VWAP ES post (with a correction note there) and to the gold hub. Working title for search: "VWAP Standard Deviation Bands Strategy on Gold: Mean Reversion Backtest on XAUUSD 5-Minute Bars".

## Reading the result
"Buried" or "Inconclusive" mean a statistically convincing edge was not demonstrated; neither is proof that none exists. Exploratory: one market, one broker's bid-only data with thin early years, tick volume instead of real volume, a holdout already used, a fixed cost instead of a historical spread.
