# Liquidity Sweep Reversal NQ (LSR-NQ) on NQ futures 2010-2019, an out-of-sample test - specification (RIP Backtest protocol v1.0 plus the 8 Oct 2026 rules)

**Specification written and frozen 2026-11-16 (approved by the owner the same day: "Aprob").** It is draft 1 plus the 2010-2026 chart the owner asked for, plus four wording fixes made before the freeze so that the text matches the code and the self-test (see the run log).

The specification was written before any level, signal or trade of these rules was computed on the 2010-2019 data. The only computations on those years were the data check (bars, gaps, volume, day ranges; see below). Once frozen, a change of a rule is a separate test; bugs may be fixed and are logged.

## Why this test, and what was looked at before
- **What it is.** Liquidity Sweep Reversal NQ is the public name, chosen by the owner on 2026-11-16, of the owner's personal NinjaTrader indicator **SweepNQ v2** (`research/nt8/SweepNQ.cs`), built with Claude on 2026-10-28. It sells after price trades above a recent high and closes back below it, and buys the mirror image.
- **These rules were designed on NQ 2020-01-01 to 2026-09-25, and that is disclosed wherever the test is reported:**
  - v1's settings were fixed before its first run: 2,621 signals, +$24 a trade, profit factor 1.05.
  - On 2026-10-28 the owner's chart showed two sells of 27 Oct stopped within minutes. Six remedies (V0-V5, `sweep_variants.js`) were then run on the same 2020-2026 data, and **V3 was picked after seeing all six results**. V3 is v2.
  - On those data v2 gives 2,253 trades, +$89 a trade after costs (+$200,843 in all), 21% winners, profit factor 1.13, every year positive except 2025.
  - **Even on its own design data the t-statistic of all trades is 1.77**, below this test's bar of 2.5. It was reproduced on 2026-11-16 with the unchanged code (see the data section).
  - These years, and October 2026 (the owner's chart), are **in-sample**. They are shown only as context and never as evidence.
- **Out-of-sample so far:**
  - the paper watch since 2026-10-29 (rules unchanged since the evening of 2026-10-28; 19 closed trades by 16 Nov, 26% winners). It becomes a separate forward test (`forward_test/LSR-NQ_nq_forward_protocol.md`);
  - and this test: **NQ 2010-2019**, ten years the rules never saw, from a second NinjaTrader export made by the owner on 2026-11-16.
- **The family, looked at before (disclosed):**
  - Change of Character NQ (4 versions; 0 passed every gate; best 2 of 6);
  - Silver Bullet ES (buried);
  - the order block and fair value gap test on EUR/USD (buried);
  - the previous day high/low reversal (Sneaky Pivot), 5 of 6 on YM, now in a paper forward test, and buried on gold;
  - an unpublished gold sweep test (October 2026, both versions buried);
  - the six SweepNQ versions above.
- **Development bar t >= 2.5**, because sweep and smart-money rules have been tried many times on this site.
- **One version only.** v2 exactly as `SweepNQ.cs` and `sweep_ref.js` run it. No variant, no new setting.
- **Why it might not work (written before any result on 2010-2019):**
  1. **Costs weigh far more in the 2010s.** The median day range was 30-60 points in 2010-2017 and 98-113 in 2018-2019, against 210-490 in 2020-2026. The rules scale with the average day range (ADR), but the cost does not: $15.76 a round trip is 0.79 point. In-sample, v2 made about **1.48% of the ADR per trade before costs** (median ADR at the signal 286 points). If it made the same share in the 2010s, the net would be about **-$7 a trade at 2010-2013 ranges, about $0 at 2016 ranges and +$13 to +$18 at 2018-2019 ranges**. So the development t-gate can fail **even if the pattern is as strong as in-sample**. A buried verdict driven by that would mean "buried by the costs of those years", and the before-cost results in ADR units (reported below) tell the two cases apart.
  2. **Three fixed sizes do not scale.** The 2-point de-duplication, the 2-tick stop buffer and the cost are 4 to 10 times larger, relative to the range, than in-sample.
  3. **Thin minutes.** The 2010-2014 overnight market was thin: 10-14% of minutes have no trade. The 5-minute confirmation then waits for the next bar on a 5-minute stamp, as the indicator would in NinjaTrader.
  4. **A selected version.** v2 was picked from six on the design data, so some of its in-sample edge is selection.

## Instrument and data
- **NQ** (E-mini Nasdaq-100 futures), `data_nq_old/NQ_1min.csv`, exported by the owner on 2026-11-16:
  - NinjaTrader, `FuturesDataExporter`, NQ DEC26, merge back adjusted, ETH;
  - 5,663,591 rows, 2010-01-03 18:01 to 2026-11-16 02:40;
  - SHA-256 34198a26f135f895ae34c1d2212dc51c54cdc7e29652c7878c5ffbbef4620a0c.
  - 1-minute bars on the New York clock, stamped at their close, with volume.
  - $20 a point; tick 0.25 point ($5).
- **Used here: bars up to 2019-12-31 17:00 New York (the cut).** Nothing later is read for this test.
- **Back-adjusted:** at each roll the older prices are shifted by the roll gap. 2010 prices are about 5,550 against a real NQ of about 1,880 (+3,670). Point moves, ranges and dollar results are unchanged by the shift.
- **The data check, `research/lsr_data_check.js`, `lsr_data_check_followup.js` and `lsr_data_check_volume.js` (outputs `.txt` beside them), run 2026-11-16 before this draft.** It computed no level, signal or trade. Findings:
  - **Format and clock:** no duplicate or backward stamp, every price on the 0.25 grid, OHLC consistent, no zero volume. The New York clock is right in every year: trading days open at 18:01, and the 09:31 bar's volume jumps at the cash open on about 100% of weekdays. No shifted week was found in 2010-2019.
  - **Back-adjustment and instrument:** against 40.6 x QQQ, no step on roll Thursdays and no wrong-instrument stretch.
  - **Old session hours:**
    - the 16:15-16:30 halt exists until 2021-06-25;
    - bars 17:01-17:15 (the session end before mid-2021) are absent in every year, in the published file too. A stop is then checked at the next evening's first bar.
  - **Holes in 2010-2019:**
    - 51 runs of 30 or more missing minutes inside a trading day. About 24 of them are 4-5 hour night holes, 20:00 (19:00 in winter) to 00:01. None in 2017-2018, one in 2019.
    - Whole days missing: 2014-01-27 to 2014-01-31 (a week), and 2013-07-11 09:30 to 2013-07-15 11:06.
    - 2012-03-20 21:06 to 2012-03-21 09:48.
    - The evenings after Christmas and New Year in 2011-2014 start at 06:01, and a few Sunday evenings start late.
  - **Thin minutes:** about 10-14% of the minutes inside trading days have no bar in 2010-2014, 7% in 2015, 5% in 2016, 2% in 2017, under 0.4% from 2018. Regular hours (09:31-16:00) are complete (median 390 bars) in every year.
  - **Rule thresholds:** a full day (600 bars) and an overnight (300 bars) are missed on only 1-3 days a year.
  - **Roll days:** from 2012, 18 roll Thursdays have 5-18% of the previous 20 days' median regular-hours volume (the thin contract that day), as in the published file. The rules use no volume.
  - **Overlap with the published `NQ_1min.csv`, 2020-01-01 to 2026-09-25:** 99.95% of 2.37 million minutes identical.
    - The new file fills the published holes of 2025-08-29 and 2026-01-23.
    - It has a bad stretch on 2026-04-06/07 that the published file does not.
    - **The in-sample context therefore stays on the published file** (SHA-256 7980d8351b388fb1daed4905dc445a1e7a6764f4072013e36a1e21605f5f15af).

## The rules (v2, frozen since 2026-10-28; the code is the reference)
New York clock, 1-minute bars timed by their close. Parameters (`sweep_ref.js` `DEF`):
- swingN 3, levelDays 3, maxDepth 0.5, windowMin 240, stretch 0.5, stretchMin 360;
- buffer 0.5, adrDays 14, minAdrDays 5, trendDays 20, minDayBars 600, minOnBars 300;
- dedupe 2, hours all, minDepth 0.02, confirm 5, stopRoom 0, adrAll false.

The rules:
- **Trading day:** 18:00 to 17:00. A bar stamped after 17:00 belongs to the next day. A **full day** has at least 600 bars.
- **ADR:** the mean high-low of the last 14 full days (at least 5 needed), fixed at the start of each trading day.
- **Trend:** the last full day's close against the mean close of the last 20 full days. It only sets the grade (A with the trend, B against). **The grade does not change any trade.**
- **Levels.** A high level gives sells; a low level gives buys.
  - **PDH/PDL:** the previous trading day's high and low, added at the first bar of a day, if that previous day was full and at most 4 calendar days back.
  - **ONH/ONL:** the high and low of the bars stamped 18:01 to 09:30, added at the first bar after 09:30, if there are at least 300 of them.
  - **60-minute swings:** clock hours built from the bars that exist. A swing high is an hour whose high is strictly above the highs of the 3 hours before and the 3 after it, among the hours present in the data, across nights and weekends. It is added when the 3rd later hour has closed, at the first bar of the next hour. Swing lows mirror this.
  - A level within 2 points of a live level of the same side is not added.
  - A level lives 3 trading days.
- **Sweep:** a bar trades beyond a level (high above a high level, low below a low level). From that bar on, the extreme beyond the level is tracked.
- **Each bar, for a swept level, in this order:**
  1. if the extreme is more than 0.5 ADR beyond the level, it is dropped (broken);
  2. else if more than 240 clock minutes have passed since the sweep bar, it is dropped;
  3. else, a **return**: a bar closes back on the level's original side, **on a 5-minute stamp** (the minute divisible by 5), with the extreme at least **0.02 ADR** beyond the level. Until such a return the level stays swept.
- **At a return** the level is used up, and a signal (SELL at a high level, BUY at a low level) is given only:
  - if the ADR exists;
  - if the **stretch** holds: over the last **360 one-minute bars** (bars, not clock minutes: in thin data they span more time), the move into the extreme is at least 0.5 ADR (for a BUY, the highest high of those bars minus the extreme);
  - and if no position in the same direction is open and no signal is already pending (a second return on the same bar is skipped, whatever its direction).
- **The virtual trade:**
  - **Entry** at the next bar's open.
  - **Stop** 2 ticks (0.50 point) beyond the sweep extreme. It is checked from the entry bar on and fills at the stop, or at the bar's open if the bar opened beyond it.
  - An **opposite signal reverses** at the next bar's open.
  - **No target, no time or session exit:** a trade is held over nights and weekends until it is stopped or reversed.
  - One position at a time.
- **Order inside a bar:**
  1. the pending order fills at the open;
  2. a new day (ADR, trend, level expiry, PDH/PDL);
  3. ONH/ONL;
  4. hourly swings;
  5. the bar joins the day, overnight and 360-bar window;
  6. the stop;
  7. sweeps and returns.
- **Data edges:**
  - after a gap or a hole, the next existing bar is the next bar (a stop is filled at its open if price opened beyond);
  - signals start once 5 full days exist (about 2010-01-11);
  - **a trade still open at the cut is closed at the close of the last bar before it** and labelled "closed at the cut".

## Costs
- **$15.76 per round trip per contract** (commission $5.76 plus one tick of slippage on each fill), as in all our NQ tests. Each trade carries the full $15.76, reversals included.
- Results in dollars per contract and in points; also before costs and at 1.5x and 2.5x the cost (descriptive).

## Periods, and the expected number of trades
- **Periods, by entry date (accepted by the owner 2026-11-16):**
  - **development 2010-01-04 to 2015-12-31** (6 years, the first signals after the warm-up);
  - **validation 2016-01-01 to 2017-12-31** (2 years);
  - **holdout 2018-01-01 to 2019-12-31** (2 years).
- **Why this split:**
  - chronological, like every test on the site;
  - development is the longest stretch;
  - the holdout falls on the cleanest years (one hole of 30+ minutes in 2018-2019).
  - **The holdout is unused:** no strategy test has used these NQ minutes before. The QQQ RSI(2) test used QQQ daily bars of those years, a different market file and rule.
- **Expected trades, from the in-sample rate (335 a year), not from the 2010-2019 data:** 200-400 a year, so about 1,200-2,400 / 400-800 / 400-800, middle guess ~2,000 / ~670 / ~670. The 50-trade gate should not bind.

## Gates and control
- **Six gates** (net dollars per contract):
  1. validation profit factor >= 1.2;
  2. at least 50 trades in each period;
  3. development **t >= 2.5**;
  4. above the 95th percentile of the control;
  5. positive without the 10 best trades;
  6. holdout net positive (**unused**).

  Fewer than 30 trades in all: Inconclusive.
- **Matched control (moved trades):**
  - Every real trade keeps its direction, its minute of the trading day (minutes since 18:00), its stop distance and its holding time.
  - **The stop distance is kept in ADR units:** the real distance divided by the ADR of the real entry's trading day, times the ADR of the new entry's trading day, rounded to the nearest tick. The day range changed three- to four-fold over these ten years, and points would mix the regimes.
  - All trades move together to other usable days (trading days of 2010-2019 with an ADR) by one random circular offset of at least 5% of them.
  - On the new day each trade enters at the open of the first bar at or after the same minute.
  - It exits at its stop (same fill rule, checked from the entry bar on) or at a time limit. The limit falls on the first bar at or after the entry plus the real holding time:
    - a trade the real rule **reversed** exits at the open of that bar, before the stop is checked, as a reversal does;
    - a trade the real rule **stopped**, or closed at the cut, has its stop checked on that bar and otherwise exits at its close.
    - Either way the control at offset 0 equals the real trades. At the cut, any control trade exits at the last close.
  - Same cost. Control trades may overlap.
  - 500 runs, seeds 1000 + run, the site's seeded generator. Statistic: the average net dollars per trade.
  - It asks whether the sweep and return pick better moments than the same trades placed on other days.
- **Rule 3 (data holes):**
  - **The holes:**
    - every run of 30 or more minutes without a bar inside a trading day, outside the 16:15-16:30 halt (to 2021-06-25);
    - every weekday on which CME was open and the file has no bar;
    - every trading day whose first bar comes after 18:15 (the time from 18:00 to that bar);
    - every trading day whose last bar comes before 16:55 (the time from that bar to 17:00).
    Exchange closures and scheduled short sessions are not holes: US holidays, the day after Thanksgiving, 24 December, 3 July, the abbreviated Good Friday sessions, and market closures for national events. They are listed in `lsr_out/lsr_holes.json` before the run, from the data and the exchange calendar.
  - **A flagged trade:** a hole lies between 18:00 of the evening that began the trading day before its signal (where its PDH/PDL, overnight and most swing levels come from) and its exit.
  - Flagged trades are reported, and every gate and verdict is recomputed without them. A changed verdict becomes Inconclusive.

## Also reported (descriptive; nothing here can change a rule or a verdict)
- **Before costs, in ADR units:** the mean result per trade divided by the ADR at the signal, by period, with its t-statistic, against the in-sample 1.48%. This separates "no pattern" from "a pattern too small for the costs of those years".
- By year, with the year's median day range and the cost as a share of it.
- Win rate with its Wilson interval, average win and loss in points and their ratio (in-sample 21%, +191 / -45), exits (stop / reverse / cut), longest losing streak, hold times.
- By level (PDH, PDL, ONH, ONL, SWH, SWL), BUY and SELL, hour group (night 16:01-03:00, London 03:01-09:30, New York 09:31-16:00, as `hourGroup` in the code), grade A and B.
- Signals a week; returns skipped and why (stretch, broken, window, same direction).
- Drawdown on closed trades; the cost sensitivity above.
- The in-sample figures beside them, labelled in-sample.
- **One chart, 2010 to 2026-09-25** (asked for by the owner on 2026-11-16).
  - **What it shows:** the cumulative net result of closed trades, by exit date.
  - **The two parts:**
    - 2010-2019 is this test's single run;
    - 2020-01-01 to 2026-09-25 is a second run of the same unchanged code on the published `NQ_1min.csv` (the 2,253 in-sample trades). That run restarts its warm-up on 2020-01-01, and the seam is marked.
  - **Labels:**
    - the 2020-2026 part is shaded and labelled "the years the rule was built on (in-sample, not evidence)";
    - the three test periods are marked.
  - **Two panels:**
    - in ADR units per trade, so years with very different day ranges are comparable;
    - in dollars per contract, where the 2020s dominate only because NQ moves 4-10 times more points a day.
  - **Rules:** no gate, verdict or statistic uses the 2020-2026 part.

## Engine and self-test (before the run)
- **Engine:** `research/nt8/sweep_ref.js`, **unchanged** (SHA-256 e443244e3ff88b288e49c2f9a373e1094de688ce5cdadc55af02744081da950d). It equals the NinjaTrader `SweepNQ.cs` v2 (SHA-256 08abfa556efaa2fd6e27cf4cccf0fda6481e9e3cc797b273250ab20c9953e122) event by event: 23,231 events, checked 2026-10-28 outside NinjaTrader.
- **`lsr_lib.js`** wraps the engine without touching its rules. It has:
  - a streaming reader of the 2010-2026 file with the cut (the shared loader reads whole files and this one is 293 MB);
  - the trade open at the cut;
  - periods, gates, control and rule 3.
- **`lsr_ref2.js`**, a separate re-implementation written from this specification, not from `sweep_ref.js`: its own reader, days, levels, swings, sweeps, returns and trade walk. It is written by the same author (Claude), not another agent, to save cost; that is stated.
- **`lsr_selftest.js`** must pass before any 2010-2019 result is printed:
  1. **Hand-built days:**
     - a PDH sweep with a return on a 5-minute stamp, and one off it (it must wait);
     - a sweep shallower than 0.02 ADR (it must wait);
     - a break beyond 0.5 ADR;
     - the 240-minute window;
     - a stretch just under and just over 0.5 ADR;
     - the 2-point de-duplication;
     - level expiry after 3 days;
     - a stop filled at the open beyond it;
     - a reversal;
     - a same-direction signal ignored;
     - a short day (no PDH/PDL next day);
     - a hole inside an open trade;
     - the trade closed at the cut.
  2. **The in-sample reproduction:** `sweep_ref.js` on the published file gives 2,253 trades and +$200,843, as on 2026-10-28 and 2026-11-16.
  3. **Engine = re-implementation, event by event** (levels, sweeps, signals, entries, exits), on 2010-2019 and on the published 2020-2026 file.
  4. **End truncation:** 10 seeded cut points. Every event before a cut equals the full run's.
  5. **Start truncation:** runs starting 2012-01-01, 2014-01-01, 2016-01-01 and 2018-01-01. After 30 trading days their levels and sweeps equal the full run's. Their signals, entries and exits are equal from the first stop exit after that point that both runs share; before it, a different open position can skip different signals.
  6. **The control at offset 0** equals the real trades.
  7. **Mutations** that must be detected by check 3 (a changed copy of the engine, the re-implementation unchanged):
     - the return on any minute (v1);
     - no minimum sweep depth;
     - the stop at the extreme without its 2 ticks;
     - the stretch over 300 bars;
     - swings of 2 hours on each side;
     - a level life of 2 days.
- **`lsr_run.js`** refuses to run unless this file's hash matches the frozen one and the self-test passed on the current code. One run, outputs in `research/lsr_out/`.

## Before the article
- The results go to the owner first, in Romanian, with every gate, whatever they are.
- An article only if the owner asks for it, at the site's pace (3-4 posts a week). Deploys only with the owner's explicit agreement.
- The forward-test page is separate and links here once this test is run.

## Reading the result
- "Buried" or "Inconclusive" mean a convincing edge was not shown on 2010-2019, not proof that none exists.
- A pass would be one market, one data source and one selected version; the forward test stays the main judge.
- The rules' fixed sizes and the cost weigh far more in these years than in the years the rules were built on. That is part of the test, not a flaw to fix after the result.

### Run log
- 2026-11-16: the data check of `data_nq_old/NQ_1min.csv` (no rule computed). The in-sample reproduction on the published file (2,253 trades, +$200,843, $89 a trade, sd $2,385, t 1.77; 1.48% of the ADR per trade before costs) and the cost projection for 2010-2019 ranges, computed on in-sample data only.
- 2026-11-16: draft 1 written. Period split accepted by the owner ("3 da"). **Not frozen.**
- 2026-11-16: wording fixes before the freeze, so that the text matches the code and the self-test (no rule changed):
  - a signal is skipped when any signal is already pending on that bar (the code's `pend`), not only one in the same direction;
  - the control's ADR is that of the entry's trading day, with the stop rounded to the tick and the time limit defined per exit type, so that offset 0 equals the real trades;
  - start truncation compares signals only from a shared flat point;
  - rule 3 also counts a day that ends early without a scheduled reason.
- 2026-11-16: the owner asked why the test cannot run from 2010 to today. Answer: it can be shown, but the 2020-2026 years cannot count, because v2 was picked on them. The owner chose to add the 2010-2026 chart with the in-sample part shaded ("da, hai sa facem asa"). It is descriptive only; no rule or gate changed. Still draft 1, not frozen.
- 2026-11-16: **frozen** (owner: "Aprob"). sha256 of this file above the "### Run log" heading: a55c3500f7c48500fa6397d4a045f2f0898b9d59476700e2a2f81f7f1f1f53b0.
- 2026-11-16, after the freeze and before any signal: `lsr_holes.js` listed the rule-3 holes (`lsr_out/lsr_holes.json`):
  - **80 holes** in 2010-2019: 50 gaps of 30+ minutes inside a day, 17 late starts, 7 early ends, 6 missing weekdays (2013-07-12 and 2014-01-27..31).
  - **Clarification applied:** until November 2012 the exchange's weekly close (Friday, or the day before an exchange closure) was 16:15 New York, so about 150 such days end at 16:15. The spec says exchange closures are not holes, so they are not counted.
  - Scheduled short sessions found: 88 (holiday halts at 11:30 until 2014, 13:00 after; the 13:15 early closes; Good Friday 2010/2012/2015 to 09:15; Sandy 2012-10-29/30; 2018-12-05). No rule changed.
- 2026-11-16, before the run: `lsr_lib.js`, `lsr_ref2.js` and `lsr_selftest.js` written. The self-test **PASSED on its first run**:
  - 19 hand-built scenarios on synthetic bars, expected events written by hand;
  - the in-sample reproduction (2,253 trades, +$200,843);
  - engine = re-implementation event by event on 2010-2019 (11,777 levels, 9,423 sweeps, 3,179 signals) and on the published 2020-2026 file;
  - end truncation (10 cuts) and start truncation (2012/14/16/18);
  - the control at offset 0 = the real trades;
  - all 6 mutations detected (`lsr_out/lsr_selftest.txt`).
- 2026-11-16, the run (`node lsr_run.js`, once; `lsr_out/`): **Buried, 3 of 6.**
  - 3,179 trades (1,945 / 598 / 636), +$3.18 a trade net, PF 1.02.
  - **Passes:** the trade count; the control (100th percentile; control median -$13.05 a trade); holdout net +$7,822 (PF 1.04; 2018 -$17,223, 2019 +$25,045).
  - **Fails:** validation PF 1.11; development t -0.43 (-$3.36 a trade); without the 10 best trades -$37,498.
  - **Rule 3:** 168 trades flagged; without them still 3 of 6, verdict unchanged.
  - **Before costs, in ADR units (descriptive):** 1.98% of the ADR a trade over all ten years (t 2.85; DEV 1.72% t 1.98, VAL 3.45% t 1.94, HOLDOUT 1.41% t 0.93), against 1.48% in-sample. The pattern is there before costs at the in-sample size, and the costs of those years take it, as projected before the run. Even before costs the development t (1.98) is below 2.5.
  - Winners 21.7% (in-sample 21%), win/loss 4.11 points ratio (in-sample 4.2).
  - `node lsr_run.js --reproduce` gave an identical result.
- 2026-11-16: published as /posts/liquidity-sweep-reversal-strategy-nq/ on 16 Nov 2026 (the owner asked for the article and the forward page on 2026-11-16: "Articol + pagina"; deployed with the owner's explicit agreement). The rule's two implementations (`nt8/sweep_ref.js`, `lsr_ref2.js`) are not published (the owner: "nu inca"). Article notes, descriptive only: the per-year before-cost figures (dollars and share of the ADR, with t) were computed from `lsr_trades.csv` by `build_lsr_post.js`; the validation share before costs is 3.44% (3.4447%; the run line above rounded the printed 3.445% to 3.45%).
