# 9 EMA strategies on NQ futures (5- and 15-minute bars, New York session) - specification (RIP Backtest protocol v1.0 plus the 8 Oct 2026 rules)

Specification written and **frozen 2026-10-14 (approved by the owner the same day, draft 1 unchanged)**, before any EMA, VWAP, signal or trade of this test was computed. Once frozen, any change of a rule is documented and treated as a separate test; bugs may be fixed.

## Why this test, and what was looked at before
- **Chosen by the owner** on 2026-10-14: the YouTube video "Master the 9 EMA: The Only Moving Average You Need?" (BKTraders, Kathy Lien and Boris Schlossberg, about 158,000 views on 14 Oct 2026; transcript supplied by the owner). It describes three uses of the 9-period EMA: (1) a trend filter (above a rising 9 EMA look only for buys, below a falling one only for sells), (2) the 9 EMA as dynamic support and resistance together with the VWAP, shown on NASDAQ 15-minute and 5-minute charts (buy a retrace to the 9 EMA when price is above both, stop below the VWAP; sell the mirror), and (3) a "break and hold" cross of the 9 EMA over the 20 EMA on 5-minute NASDAQ charts, stop below the 20 EMA. The video gives no profit target; it says that a fall back through the 9 EMA means the trend has changed.
- Choices made by the owner the same day: **NQ futures**; setups (2) on 5- and 15-minute bars and (3) on 5-minute bars, long and short; **exit on a close back through the 9 EMA** for setup (2) and **on the opposite cross** for setup (3), besides the stop and the session close. Use (1) is a filter, not a strategy with entries and exits; it is built into setup (2).
- Earlier tests: EMA 9/20 crosses on gold (15-minute and 1-hour) and EMA 9/21 crosses on ES, NQ and gold futures (1-hour), the NQ ribbon (EMA 5/8/13), and VWAP strategies on ES (5-minute). No 9 EMA retrace and no 9/20 cross on 5-minute NQ was looked at. Because EMA crosses have been tried in many variants on the site, the development t-statistic bar is **2.5**.

## Instrument and data
- **NQ** (E-mini Nasdaq-100), 1 contract, NinjaTrader's back-adjusted 1-minute file with real contract volume (`na_lib.load('NQ')`, as in the noise area test), 2020-01-01 to 2026-09-25 17:00 New York.
- **Session:** 09:30 to 16:00 New York, or the exchange's earlier close (calendar of `rb_lib.js`). **Bars:** 5- and 15-minute bars inside the session (the first closing at 09:35 or 09:45), built from the minutes that exist.
- **EMAs** of the closes of the session bars, carried from one session to the next (a chart showing the regular session only), seeded with the simple average of their first values. **VWAP:** the session VWAP of the VWAP test on ES (typical price x volume of the session's bars, reset every session).
- **Holes (rule 3):** `data_holes.json`; trades open across a known hole are counted, and every gate and verdict is recomputed without them.

## The setups (signals only from the session's second bar on, and never on its last bar)
- **9 EMA + VWAP pullback (E9-VWAP):** a **long signal** at the close of bar k when (a) the previous bar closed above both the VWAP and the 9 EMA, (b) the 9 EMA is rising (EMA9[k] > EMA9[k-1]), (c) bar k traded at or below the 9 EMA (the retrace), and (d) bar k closed back above the 9 EMA and above the VWAP (the confirmation). **Stop:** one tick ($0.25) below the VWAP at bar k, fixed. **Exit:** after the first bar that closes below the 9 EMA (the video's "trend has changed"), at the stop, or at the session close. **Short:** the mirror image. One position at a time.
- **9/20 break and hold (E9-X20):** a **long signal** at the close of bar k when the 9 EMA crosses above the 20 EMA (EMA9[k] > EMA20[k] and EMA9[k-1] <= EMA20[k-1]); **stop** one tick below the 20 EMA at bar k, fixed. **Exit** at the opposite cross (which also opens the opposite position, a flip), at the stop, or at the session close. **Short:** the mirror image.
- **Execution:** entries, flips and exits at the open of the first minute after the signal bar; stops checked on every minute from the entry minute on (stop first); a stop gapped through fills at the minute's open; no trade if the entry price is already beyond the stop.
- **Three variants:** **E9-VWAP-M5, E9-VWAP-M15, E9-X20-M5**, all long and short.

## Costs and results
- **$15.76 per contract per round trip** (commission plus one tick of slippage on each fill), as in every NQ test on the site; a flip pays two. Results in **dollars per contract**.

## Periods, gates, control
- **Periods (by entry date):** development 2020 to 2023; validation January 2024 to March 2025; holdout April 2025 to September 2026 (**already used** by earlier NQ tests).
- **Six gates per variant:** validation profit factor >= 1.2; at least 50 trades in each period; development **t >= 2.5**; 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: Inconclusive.
- **Matched control (moved entries):** every real entry moved, all together, by one random circular offset of at least 5% of the sessions, to the same minute after the open in another session, same direction, the same stop distance in points, then managed by the same exit rule (a close through the 9 EMA, or the opposite cross) and the session close; one position at a time, no flips; same costs. 500 runs, seeds 1000 + run. Statistic: the average net dollars per trade.

## Engine and self-test (before the run)
A new engine (`e9_lib.js`) and a self-test that must pass before any result is printed:
1. Hand-worked cases: the EMAs and their seed carried across sessions; the VWAP; each condition of the pullback signal; the cross; the stops (also in the entry minute and gapped); the 9 EMA exit and the cross exit with its flip; no signal on the first or last bar of a session; an early close.
2. Session bars, the EMAs and the VWAP against a naive recomputation on the real data.
3. An **independent re-implementation** matched trade by trade for all three variants on the real data.
4. The control at offset 0 reproduces the real trades.

## Before the article
Results go to the owner first: all three variants, every gate, long and short separately, trades per day, results before and after costs, by year and by hour, how trades ended, the hole check. One article (NQ), published only with the owner's agreement; the video is linked (nofollow) and described in our own words.

## Reading the result
"Buried" or "Inconclusive" mean a statistically convincing edge was not demonstrated; neither is proof that none exists. One market, the setups as described in the video, our fixed readings of its open points (the exit, what counts as a retrace and a confirmation).
