# The Holy Grail (Raschke and Connors) on ES futures, 5-minute and 60-minute bars, 2010-2019 with a 2020-2026 replication - specification (RIP Backtest protocol v1.0 plus the 8 Oct 2026 rules)

**Specification written and frozen 2026-11-18 (approved by the owner the same day: "Aprob"). It is draft 2 with two later changes (see the run log).** Draft 2 answers a review of draft 1 pasted by the owner on 2026-11-18 (see the run log).

The specification is written before any ADX, moving average, setup, signal or trade of this test is computed on any market. The only computations on this file so far are the data check of 2026-11-17 (bars, gaps, clock, rolls, 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
- **Chosen by the owner** on 2026-11-16 ("Holy Grail ES"). The design direction was accepted by the owner on 2026-11-17: "facem cum o facem noi pe regulile noastre si pastram ce creezi tu". The ES history back to 2010 was exported by the owner for it on 2026-11-17.
- **The idea.** Linda Bradford Raschke and Laurence A. Connors, *Street Smarts: High Probability Short-Term Trading Strategies* (1995), the chapter "Holy Grail". A buy (sells are the mirror image), as the book is usually summarised:
  1. a 14-period ADX initially above 30 and rising (a strong trend);
  2. a retracement to the 20-period exponential moving average, usually with a turndown in the ADX;
  3. when price touches the average, a buy stop above the high of the bar;
  4. once filled, a protective stop at the newly formed swing low; exit at the recent swing high, or trail if the market is strong;
  5. if stopped out, one re-entry at the original entry price;
  6. after a successful trade, the ADX must turn up again before another entry.
- **Three layers, kept apart here and in the article:**
  - **what the idea says** (rules 1 to 3, on which the pages we read agree);
  - **what we rebuild without the book's text** (rules 4 to 6, the exact state machine below, the 1-tick buffers);
  - **what we add** (the 5-bar trailing stop, the intraday bar sizes, the ES market). Our additions are labelled as ours wherever the test is reported.
- **What we could and could not check (2026-11-18).** We did not have the book. Secondary pages agree on rules 1 to 3 and differ on the rest:
  - **The average.** The Right Trader says a 20-period **EMA**, as the book. Trading Setups Review (Galen Woods) writes the rules with a 20-period **SMA**, and Capital.com calls the SMA the usual choice. **We use the EMA, as the book, and say so.** The SMA is one of the self-test's mutations; it is not a variant.
  - **The order.** The book's wording is "above the high of the previous bar" once price touches the average. Trading Setups Review and Capital.com place it at the high of the bar that touched. We use the touching bar (the "setup bar"), 1 tick above its high, valid for the next bar only.
  - **The exits and the re-entry.** The Right Trader, restating a 1997 interview, says the authors name no price target and trail the stop. No page we read gives the re-entry or the after-a-winner rule. Rules 4 to 6 are taken as the book is usually summarised and as accepted on 2026-11-17; the exact book text could not be checked, and the article will say so.
- **Other tests, not cited (owner, 2026-11-18):** at least one other site has published a test of the setup on daily bars of other markets (no ES, no intraday bars), with other rules. This test is designed on its own; the article neither cites nor compares with it.
- **Our reading of rule 1 ("initially").** The ADX condition is checked **when the trend starts**, not at the touch: the side is armed when the ADX turns up above 30 (or crosses 30 while rising), and the first pullback to the EMA is taken **while the trend still holds**: the ADX may be falling, but it must still be above 30, with the DI lines in the trade's direction. This follows "initially" and "usually with a turndown in the ADX". The strict reading (ADX rising at the touch itself) is counted among our setups and reported (descriptive).
- **Looked at before on this site (disclosed):**
  - **The trend-pullback family, all Buried:** gold 5-minute trend pullback (4 versions, best 1 of 6), Bitcoin intraday trend pullback (2, best 1), 9 EMA NQ (3, best 1), Fibonacci 61.8% pullback EUR/USD (2, best 1), DAX Fibonacci pullback (2, 0), Fibonacci scalping ES "Golden Zone" (4, best 1), anchored VWAP pullback EUR/USD (2, best 2): **7 tests, 19 versions**.
  - **The ADX:** the ADX + DI test on four forex majors (8 versions, best 2 of 6); the ADX filter of the Parabolic SAR EUR/USD test (best 1 of 6); ADX as a filter in unpublished Coppock ES work (September 2026, disclosed in cc_spec.md).
  - **On ES, all Buried:** Supertrend, Donchian, MACD, Bollinger, RSI(2), RSI divergence, VWAP, TheStrat, Silver Bullet, NR7, gap fill, Initial Balance, noise area, intraday momentum, Fibonacci scalping, Standard Error Bands, Market Profile 80% rule. All of them used ES 2020-2026 only.
  - The site's only survivor on index futures is the noise area breakout on NQ (New York session).
- **Development bar t >= 2.5**, because the trend-pullback family has 19 versions on the site, far more than four. This is a stricter bar for a crowded family, **not a full correction for multiple testing**; the article says so.
- **Why it might not work (written before any result):**
  1. **The strict reading barely trades.** If the ADX must still be rising at the touch, setups are rare, because pullbacks usually come with a falling ADX (the book itself says so).
  2. **The ADX lags.** By the time a 14-bar ADX is above 30, much of the move may be over; a high ADX can also mean an overdone trend (Trading Setups Review says so).
  3. **Costs in the 2010s.** $30.76 a round trip (0.62 point) is about 3.5% of the median ES day range of 2010-2017 (17.5 points), against about 1% in 2020-2026 (62.5 points). On 5-minute bars of 2010-2013 the distance from the entry to the pullback low will often be a few points, so the cost can be a large part of the risk.
  4. **The target is near.** The entry is above the pullback bar and the target is the high the pullback came from, so the reward can be smaller than the risk on many trades.
  5. **Re-entries pay twice.** A stopped trade that re-enters at the same price pays the cost again.

## Instrument and data
- **ES** (E-mini S&P 500 futures), `data_es_old/ES_1min.csv`, exported by the owner on 2026-11-17:
  - NinjaTrader, `FuturesDataExporter`, ES DEC26, 1 minute, ETH (all trading hours), merge back adjusted;
  - 5,864,916 rows, 2010-01-03 18:01 to 2026-11-17 03:40; 292,976,045 bytes;
  - SHA-256 abba095b578471ead0055c9cf709fbb0740559ee9af11e637f46b22b5081ed95.
  - 1-minute bars stamped at their close, with volume. $50 a point; tick 0.25 point ($12.50).
- **Clock:** New York wall-clock time, with the US daylight-saving changes, as in the file. The data check confirmed it in every year (below).
- **The continuous series:** NinjaTrader's "merge back adjusted": the front contract until NinjaTrader's roll date (the Thursday about eight days before each quarterly expiry), then the next; at each roll all older prices are shifted by the gap between the two contracts. 2010 prices are about 640 points above a real ES. Point moves, ranges and dollar results are unchanged by the shift. **The indicators run across rolls without a reset**, as on a back-adjusted chart.
- **Two runs read the file:**
  - **the test** reads bars up to **2019-12-31 17:00 New York** (its cut) and nothing later;
  - **the replication** reads bars up to **2026-11-16 17:00** (the end of the last full trading day in the file).
- The published `ES_1min.csv` (2020-2026) is not used and never modified; on its years the two files are 100.00% identical (below).
- **The data check, `research/es_data_check.js`, `es_data_check_followup.js` and `es_data_check_volume.js` (outputs `.txt` beside them), run 2026-11-17.** It computed no indicator, setup or trade. Findings:
  - **Format and clock:** no duplicate or backward stamp, no OHLC or tick-grid error, no zero volume. Trading days open at 18:01; the 09:31 bar's volume jumps at the cash open on 98-100% of weekdays in every year: the New York clock is right. No shifted week in 2010-2019.
  - **Back-adjustment and instrument:** against 9.98 x SPY, no roll Thursday steps more than 20 points; no wrong-instrument stretch.
  - **Old session hours:** the 16:15-16:30 halt until 2021-06-25; bars 17:01-17:15 absent in every year; until November 2012 the Friday session ended at 16:15.
  - **Holes:** 35 runs of 30 or more missing minutes inside a trading day in 2010-2026, mostly 4-hour night holes (20:00 to 00:01) around rolls in 2010-2016; 2012-03-20 21:07 to 2012-03-21 09:48; whole weekdays missing 2014-01-27 to 2014-01-31; the evenings after Christmas and New Year 2011-2014 start at 06:01; short days 2011-04-29, 2013-07-15, 2013-12-27.
  - **Thin minutes:** overnight, about 5-11% of minutes in 2010-2017 traded 5 contracts or fewer; regular hours are complete (median 390 bars) in every year.
  - **Mis-stamped week:** 2020-10-19 to 2020-10-22 (as in the published file and in NQ): heavy trading at night, ~0 volume in regular hours, a 05:49-06:49 hole each day; 2020-10-23 has no regular-hours volume.
  - **Roll Thursdays:** 38 of 40 in 2010-2019 hold about 0.30x normal volume (the old contract that day); prices are right. The rules use no volume.
  - **Overlap with the published `ES_1min.csv`, 2020-01-01 to 2026-09-25:** 2,378,023 of 2,378,027 minutes identical OHLCV (4 differ in volume only), the same 9 holes on both sides.

## The chart and the indicators
- **Trading day:** 18:00 to 17:00 New York; a bar stamped after 17:00 belongs to the next day. **A full day** has at least 600 one-minute bars.
- **Two charts, each a separate test of the same rules:**
  - **5-minute bars:** bar E holds the minutes stamped E-4 to E (the first bar of a day closes at 18:05).
  - **60-minute bars, aligned on the clock hour:** bar E holds the minutes stamped E-59 to E (18:00-19:00 closing 19:00, ..., 16:00-17:00 closing 17:00): 23 bars on a full day.
- **Bar building:**
  - bars are built from the minutes that exist; a slot with no minute has no bar, and the next existing bar is the next bar;
  - **the daily break** (17:00-18:00) and **weekends** have no bars; the chart goes from the last bar before the break to the first bar after it;
  - **holidays and short sessions** stay on the chart as they traded (this is a full Globex chart, not a regular-session one): a 13:00 holiday close leaves no bars until 18:00; the old 16:15 Friday close (to November 2012) and the 16:15-16:30 halt (to June 2021) make the last hourly bar shorter;
  - **night and day bars form one continuous chart** across days, weekends and rolls, as on a 24-hour futures chart.
- **EMA(20)** of the closes: k = 2/21; the first value is the simple average of the first 20 closes of the file.
- **ADX(14) with +DI and -DI, Wilder's method**, exactly as in our ADX forex test (`adx_spec.md`): true range and directional movement from consecutive chart bars; Wilder smoothing (first value the sum of 14, then S - S/14 + x); DX = 100 x |+DI - -DI| / (+DI + -DI) (0 if the sum is 0); ADX the mean of the first 14 DX, then (13 x ADX + DX) / 14.
- **Signals from the 500th chart bar** of the file (about 2010-01-06 on 5-minute bars, about 2010-02-03 on 60-minute bars): the smoothing has no memory of its start after that.
- **ADR** (for the control and for reporting only, never for a rule): the mean high-low of the last 14 full trading days (at least 5), fixed at the start of each trading day.

## The rules (a buy; a sell is the mirror image, with +DI and -DI swapped, highs and lows swapped)
Everything is decided at the close of a chart bar, from that bar and earlier ones only. Fills and exits are walked on 1-minute bars.

**Definitions, at the close of bar k:**
- **The long trend holds** when ADX(k) > 30 and +DI(k) > -DI(k). The short trend holds when ADX(k) > 30 and -DI(k) > +DI(k).
- **A long arm event** happens when the long trend holds, ADX(k) > ADX(k-1) (rising), and the ADX has just turned up or crossed 30: ADX(k-1) <= ADX(k-2), or ADX(k-1) <= 30. A short arm event is the same with -DI above +DI.
- **A touch (long)** at bar k: low(k) <= EMA(k), and close(k-1) > EMA(k-1). A short touch: high(k) >= EMA(k), and close(k-1) < EMA(k-1).

**The state machine (one machine per version; one state at a time, so at most one setup and one position):**

| State | What happens at each bar close (in this order) | Next state |
|---|---|---|
| **IDLE** | an arm event (long or short) | ARMED (that side), the arm bar a = this bar |
| **ARMED** | 1. the armed side's trend no longer holds (ADX <= 30, or the DI lines equal or crossed): the arm is **cancelled**; if this same bar is an arm event for the other side, that side is armed at once | IDLE (or ARMED, other side) |
| | 2. else, a touch on this bar (bar s, after a) is the **setup bar**: the levels are fixed (below) | ORDER, or IDLE if there is no room |
| | 3. else, a new arm event on the same side changes nothing (a stays the first arm bar) | ARMED |
| **ORDER** | the entry order is live during bar s+1 only (its minutes); filled: TRADE; not filled by s+1's close: the setup is **unfilled** | TRADE, or IDLE |
| **TRADE** | the exits are walked on the minutes; TRL updates its stop at each close; exit at a loss: RE-ORDER if the trend end T has not closed yet, else IDLE; exit without a loss: IDLE | RE-ORDER or IDLE |
| **RE-ORDER** | the re-entry order is live from the minute after the loss exit until the close of bar T; filled: RE-TRADE; T closes first: expired | RE-TRADE, or IDLE |
| **RE-TRADE** | the exits as in TRADE; at any exit | IDLE |

- **Arm events are ignored in every state except IDLE and ARMED.** So after any setup ends, a winner included, the ADX must turn up again (or cross 30 again) after that end before the next setup. This is rule 6 of the book applied to every outcome, because rule 2 asks for the first pullback of a trend. An arm event on the very bar a setup ends (IDLE is reached during that bar's walk) counts.
- **The trend end T** of a setup is the first bar close after s at which the setup's side no longer holds its trend. It is found from the data as the bars close; it may come before, during or after the trade.

**The levels, fixed at the close of the setup bar s:**
- **the recent swing high H:** the bar with the highest high from a to s (ties: the latest); **target** = high(H);
- **entry** = high(s) + 1 tick (a buy stop);
- **the pullback low** = the lowest low of bars H to s; **stop** = the pullback low - 1 tick;
- **no room:** if the target is not above the entry level, no order is placed; the setup ends (counted as "no room"). There is **no minimum reward**: a target 1 tick above the entry is a valid trade, as the book gives none.

**Fills (entry and re-entry orders):**
- a buy stop fills at the first minute whose high reaches its level, **at that level**, or **at the minute's open if the minute opened at or above it** (a gap; the worse price is taken). Sells mirror this.
- **If the fill price is at or above the target, the trade is not taken** (counted as "filled beyond the target"; for the first order the setup then ends, for a re-entry the re-entry ends).

**Exits, two versions** (walked on 1-minute bars):
- **TGT, the book's target (the reference version):** the stop or the target. A level a minute opens beyond fills at that open. **Stop and target in the same minute: the stop** (the order inside a minute is unknown; the worse case is taken). **In the fill minute only the stop is checked**, for the same reason.
- **TRL, a 5-bar trailing stop (our experimental addition, not the book's rule; the book says only "trail"):** no target. At each chart bar close from the bar that holds the fill minute, the stop moves to the lowest low of the last 5 chart bars - 1 tick, if that is higher; it never moves down; the new level applies from the next minute. Same fill rules.
- **No time or session exit:** trades are held through the 17:00-18:00 break, nights and weekends; a stop gapped through at a reopen fills at that open.
- A trade open at a run's cut is closed at the last close before the cut, labelled "closed at the cut"; a live order at the cut is cancelled.

**The re-entry (rule 5 of the book):**
- **Only after a first trade that exits at a loss** (exit price below the entry price for a long, above for a short). Never after a target, a trailing exit at or above the entry, or an unfilled order. The original order is not live after the exit; the re-entry is a new order.
- **At the original entry level**, live from the minute after the loss exit until the close of bar T (if T has already closed, there is no re-entry). Same fill rules.
- **Its stop** = the lowest price traded from the first fill minute through the re-entry fill minute - 1 tick. TGT keeps the original target; TRL trails as above.
- **At most one re-entry per setup.** Re-entries are **logged as separate trades** (type RE, first trades type FT), each with its own cost.

**Not part of the rule:** the SMA reading, a minimum reward-to-risk, volume, a session filter, a time stop. The 1-tick buffers and the 5-bar trail are the only numbers added to the book's (14, 30, 20); each is fixed here once.

## Versions (4)
| ID | Chart | Exit | Role |
|---|---|---|---|
| HG5-TGT | 5-minute | the book's target (recent swing high) | reference |
| HG5-TRL | 5-minute | 5-bar trailing stop | our experimental change |
| HG60-TGT | 60-minute | the book's target | reference |
| HG60-TRL | 60-minute | 5-bar trailing stop | our experimental change |

Long and short are in every version; they are reported separately but not gated separately. The TGT and TRL versions of a chart share their setups up to the first exit; after it, their re-entries and later setups can differ. Each version gets its own verdict; the article labels TRL as our change wherever it appears.

## Costs
- **$30.76 per round trip per contract, about 2.46 ticks**, as in all our ES tests (our model, not a broker's quote):
  - **commission and fees: $5.76** a round trip, the broker's commission and the exchange and regulatory fees together;
  - **spread and slippage: 1 tick ($12.50) on each fill**, $25 a round trip. The file holds traded prices, so no separate spread is charged: a buy stop fills at the level or worse, and the tick per fill stands for crossing the spread and for slippage. A limit fill at a target may get no slippage in reality; the full cost is kept.
- **A re-entry pays its own $30.76.**
- **The tick of slippage is charged on every fill of every kind:** stop entries, re-entries, stop exits, target exits, trailing exits, gap fills and the close at the cut. The cost is a fixed charge per trade; a fill price is never moved by it.
- **Rolls:** prices are back-adjusted, so a price difference inside one contract equals the real contract's, and fills on the continuous series are real prices shifted by a constant. A trade held across a roll would in reality be rolled: it is charged **one extra $30.76 for each roll date (the second Thursday of March, June, September and December) on which it is open at 17:00**, as in our golden cross ES test. Counted and reported.
- **Sensitivity (descriptive), the whole cost multiplied (commission, fees and slippage, roll charges included):** before costs; 1.5x ($46.14, about 3.7 ticks a round trip); 2.5x ($76.90, about 6.2 ticks). The verdict uses the base cost.
- Results in dollars per contract, in points and in R (the entry-to-stop distance), with the cost in R (median) by bar size and year.

## Periods
**The test (gated), by fill date, on bars to 2019-12-31 17:00:**
- **development 2010 (first signal after the warm-up) to 2015-12-31** (6 years);
- **validation 2016-01-01 to 2017-12-31** (2 years);
- **holdout 2018-01-01 to 2019-12-31** (2 years), **unused**: no test on this site has computed anything on ES minutes before 2020. Disclosed: the Liquidity Sweep Reversal NQ test used NQ 2018-2019 as its holdout (another index future, highly correlated), and our SPY daily tests cover 1993-2026 (another instrument, daily bars).

**The replication (descriptive, not gated): 2020-01-01 to 2026-11-16 17:00.**
- A second run of the unchanged code on the whole file to 2026-11-16 17:00; **the trades filled from 2020-01-01 on** form the replication (the indicators run on from 2010; trades filled earlier are the test's).
- **Already used:** every earlier ES test on this site ran on ES 2020-01-01 to 2026-09-25; only 2026-09-26 to 2026-11-16 is fresh. The Holy Grail was never computed on any of it.
- It gets the same statistics as the gates (profit factor, t, the control with its own 500 runs on 2020-2026 days, without the 10 best trades, net), shown beside the test's. **It cannot change a verdict.** It answers whether the result of 2010-2019 looks the same in the later years, where the cost weighs about a third as much relative to the day range.
- **Why this split** (from the review of 2026-11-18, accepted in this draft): the gated holdout is one no rule on the site has seen; the price is a short holdout (two years) and a verdict decided in the decade where costs weigh most. The before-cost figures in ADR units and the replication are shown so that a verdict driven by costs can be told apart.

**Expected number of trades (for planning only; not published):** 60-minute bars roughly 20 to 60 trades a year, so about 120-360 / 40-120 / 40-120 in the three periods; 5-minute bars roughly 250 to 700 a year. Our flag test guessed ten times too many, so this is only a guess. **The 60-minute versions may fail the 50-trade gate in validation or the holdout**; the protocol then applies unchanged.

## Gates and control
- **Six gates per version** (net dollars per contract, the test's trades only):
  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 setups), 500 runs:**
  - **Which setups move:** every real setup that placed an entry order (filled or not), so the control has the same number of setups as the real test.
  - **What each keeps:** its direction; the minute of the trading day of its setup bar's close; its stop and target distances from the entry level; its trend life (the number of chart bars from s to T).
  - **Distances in ADR units:** the real distance divided by the ADR of the real setup's trading day, times the ADR of the new trading day, rounded to the tick (at least 1 tick). The median day range changed three- to four-fold from 2010 to 2026.
  - **The move:** all setups move together to other usable trading days (with an ADR, inside the run's own years) by one circular offset of at least 5% of them, drawn by `mulberry32(1000 + run)`, the site's seeded generator (`A.randomShift`, as in every control on the site).
  - **On the new day:** the setup bar is the chart bar closing at the same minute of the trading day, or the first one after it that day (none: dropped). The entry level is 1 tick beyond that bar's high (long) or low (short); the order is live for the next bar. The exits (TGT: stop and target; TRL: the initial stop and the 5-bar trail on the new bars), the re-entry (after a loss, at the entry level, until the same number of bars after the setup bar as the real trend life) and the costs are the same.
  - Moved setups are simulated one by one and may overlap.
  - **Statistic:** the average net dollars per filled trade. The real average is placed in the distribution of the 500 control averages (its percentile, with the control's median and 5th-95th percentiles shown), not compared with their mean alone.
  - **At offset 0 the control equals the real trades** (checked by the self-test).
  - It asks whether the ADX and EMA conditions pick better bars than the same orders, risk and target placed at the same time of day on other days.
- **Rule 3 (data holes):**
  - **The holes,** listed in `hg_out/hg_holes.json` before any setup is computed, from the data and the exchange calendar:
    - 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, or whose last bar comes before 16:55;
    - the mis-stamped days 2020-10-19 to 2020-10-22, and any day with no regular-hours volume that is not an exchange closure (2011-04-29, 2013-12-27, 2020-10-23).
    - Exchange closures and scheduled short sessions are not holes (US holidays, the day after Thanksgiving, 24 December, 3 July, the abbreviated Good Friday sessions, closures for national events, and the 16:15 Friday close until November 2012).
  - **A flagged trade:** a hole lies between 18:00 of the evening that began the trading day before its arm bar's trading day and its exit.
  - Flagged trades are reported, and every gate and verdict is recomputed without them. A changed verdict becomes Inconclusive. The same flags are shown for the replication.

## Also reported (descriptive; nothing here can change a rule or a verdict)
- **The funnel and the setup frequency:** arm events, arms cancelled before a touch, setups a month and a year, no room, **unfilled setups**, fills beyond the target, first trades, re-entry orders, re-entry fills and expiries; their share of all setups, by year.
- **The strict reading:** how many of our setups had the ADX still rising at the setup bar (the strict reading), and those trades' results.
- **Before costs, in ADR units:** the mean result per trade divided by the ADR, by period and year, with its t-statistic, beside the cost as a share of the median day range.
- First trades and re-entries separately; win rate with its Wilson interval; average win and loss in points and R; reward-to-risk at entry (target distance / stop distance, TGT); the share reaching the target; exits by reason; holding times (and the share held overnight); longest losing streak.
- Long and short; hour of the setup (night 16:01-03:00, London 03:01-09:30, New York 09:31-16:00); by year; drawdown on closed trades; the cost sensitivity above.
- The replication, with the same items.

## Engine and self-test (before the run)
- **`hg_lib.js`**, the engine: a streaming reader of the 293 MB file with the cut (as `lsr_lib.js`), the bars, EMA, ADX/DI, the state machine, the 1-minute walk, periods, gates, control and rule 3.
- **`hg_ref.js`**, a separate re-implementation written from this specification, not from the engine: its own reader, bars, indicators, state machine and trade walk. It is written by the same author (an AI, Claude), not by an independent person or agent, to save cost; that is stated.
- **`hg_selftest.js`** must pass before any result is printed:
  1. **Indicators by hand** on built bars: EMA seed and steps; +DI, -DI, DX and ADX through the Wilder seeds.
  2. **Hand-built charts, one per transition of the state machine:**
     - an arm on a turn up above 30, on a cross of 30 while rising; no arm on a falling ADX, at exactly 30, or with +DI = -DI;
     - a second arm while ARMED (a unchanged); arm events in ORDER, TRADE, RE-ORDER and RE-TRADE (ignored); an arm on the bar a setup ends (counted);
     - cancellation by ADX falling to 30 and by the DI lines crossing, before the touch; a cancellation and an opposite arm on the same bar;
     - a touch with the low exactly at the EMA (setup), 1 tick above (none); a touch whose previous bar closed at the EMA (none); a touch on the arm bar itself (none);
     - the swing-high tie rule; the pullback low; no room; a target 1 tick above the entry (taken);
     - the entry at the level, at a gap open above it, not filled in the next bar (unfilled), a fill at or above the target (not taken);
     - TGT: target, stop, both in one minute (stop), a gap through each, the fill minute's stop;
     - TRL: the update time, the 1-tick buffer, never moving down, an exit above the entry (no re-entry);
     - the re-entry: after a loss only, at the original level, its stop, a gap fill, its expiry at T, no re-entry when T closed before the exit, only once;
     - after a winner, no setup until a new arm after the exit;
     - bars across the 17:00 break, a 13:00 holiday close, the old 16:15-16:30 halt and 16:15 Friday close, a weekend, a missing slot, a roll day;
     - the trade closed at the cut and the order cancelled at the cut.
  3. **Engine = re-implementation**, setup by setup (including unfilled and no-room setups) and trade by trade, for the four versions, on the test (to 2019) and on the replication (to 2026-11-16), and indicator values at 1,000 seeded bars.
  4. **End truncation:** 50 seeded cut points; every setup, fill and exit before each cut equals the full run's.
  5. **Start truncation:** runs starting 2012-01-01, 2014-01-01, 2016-01-01, 2018-01-01, 2021-01-01 and 2024-01-01; after 500 bars their indicators equal the full run's within 1e-6, and their setups and trades are equal from the first bar at which both runs are IDLE.
  6. **The control at offset 0** equals the real trades, for the test and the replication.
  7. **Mutations** that check 3 must detect (a changed copy of the engine, the re-implementation unchanged):
     - a 20 SMA instead of the 20 EMA;
     - the arm without "rising";
     - a setup allowed with ADX at or below 30;
     - the stop without its tick;
     - the entry order live for 2 bars;
     - the target at the highest high of the last 20 bars;
     - a 4-bar trail;
     - no re-entry.
- **`hg_holes.js`** lists the rule-3 holes before any setup is computed.
- **`hg_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 of the test and one of the replication; outputs in `research/hg_out/`.

## Before the article
- Results go to the owner first, in Romanian, with every version and 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.
- **Working title:** "Holy Grail Trading Setup: An Independent Intraday Backtest on ES Futures" (search volume not measured; the pages ranking for "holy grail trading strategy" on 2026-11-18 are explainers, TradingView scripts, an MQL5 article and a daily-bar test on other markets; none tests ES or intraday bars). Never "the original Holy Grail, tested": every departure from the usual wording is listed in the article.
- The article does not cite or compare with other sites' tests. It says the book text could not be checked, names the SMA reading, and labels the trailing stop as ours.
- If published, whether it joins the day-trading guide is decided at the next weekly recompute (the trades use intraday bars but are held overnight).

## Reading the result
- "Buried" or "Inconclusive" mean a convincing edge was not shown on ES 2010-2019, not proof that none exists.
- A pass would be one market, one data source and one reading of a setup traders apply by eye; it would be a hypothesis worth a forward test, not proof of a "holy grail".
- The result covers one market, two bar sizes, one reading of "initially" and two exits. The daily chart of the book is not tested here.
- Costs weigh more than three times more, relative to the day range, in 2010-2017 than in 2020-2026; the before-cost figures in ADR units and the 2020-2026 replication are shown so that a verdict driven by costs can be told apart.

### Run log
- 2026-11-17: the data check of `data_es_old/ES_1min.csv` (no indicator, setup or trade computed).
- 2026-11-18: sources checked (Trading Setups Review, The Right Trader, Capital.com, an MQL5 article); the book itself was not available. Draft 1 written. Not frozen.
- 2026-11-18: draft 2, after a review of draft 1 written by another AI and pasted by the owner. Nothing computed. Changes:
  - **periods:** the gated test is now 2010-2019 (development 2010-2015, validation 2016-2017, an unused holdout 2018-2019), with 2020-2026 as a descriptive replication (draft 1: development 2010-2017, validation 2018-2021, a mostly used holdout 2022-2026);
  - the rules are written as an explicit state machine (no rule changed: a second arm while armed keeps the first arm bar; a cancellation and an opposite arm on one bar; arm events ignored while a setup is active);
  - the re-entry, the target check at the fill and the absence of a minimum reward are spelled out; re-entries are logged as separate trades;
  - the cost breakdown, the bar building, the clock and the continuous series are documented; the control's generator is named and the real result is placed in the control's distribution;
  - the article's title, the labels "reference" (TGT) and "our experimental change" (TRL) are fixed; the trade-count guess is for planning only.
- 2026-11-18: after a second pasted review: the slippage tick is stated for every kind of fill, the sensitivity multiplies the whole cost, and a trade held across a roll date pays one extra round trip (the only rule added). Not frozen.
- 2026-11-18: the owner asked not to cite or compare with other sites' tests of this setup ("nu are nici o importanta ce teste au facut"); the prior-work block and every mention of that site were replaced by one neutral line. No rule changed. Not frozen.
  - **Not frozen.**
- 2026-11-18: **frozen** (owner: "Aprob"), draft 2 with the two later changes above (no citation of other sites' tests; the roll charge and the cost wording). sha256 of this file above the "### Run log" heading: bb0a955692824ed65b1365dc1c97dac5cd833bf9f949cddaab298988165f7562.
- 2026-11-18, after the freeze and before any setup: `hg_holes.js` listed the rule-3 holes of 2010-01-03 to 2026-11-16 (`hg_out/hg_holes.json`): 71 holes (gaps of 30+ minutes, late starts, early ends, the missing week of January 2014, the four mis-stamped days of October 2020 and three days with no regular-hours volume). No rule changed.
- 2026-11-18, before the run: `hg_lib.js` (engine: whole setups simulated from their levels), `hg_ref.js` (separate re-implementation: one minute-by-minute pass with the state machine of the spec's table, its own reader, bars, indicators and roll dates) and `hg_selftest.js` written. The engine and the reference agreed on every setup and trade at their first comparison (counts only printed). The first self-test run failed 4 of 62 checks, all the start-truncation check: the engine did not return its record of IDLE bars, so the test found no common IDLE bar. The engine now returns it (no rule or result touched); the self-test then **PASSED 62 of 62**: indicators and bar building by hand; 25 hand-built runs with the expected setups and trades written by hand; engine = reference on the test and the replication for the four versions (e.g. HG5-TGT 10,237 setups and 2,307 trades in 2010-2019; HG60-TGT 890 and 307); end truncation (50 cuts per version) and start truncation (6 starts per version); the control at offset 0; the 8 mutations detected (`hg_out/hg_selftest.txt`).
- 2026-11-18, the run (`node hg_run.js`, outputs in `hg_out/`). The first attempt stopped on a reporting bug after printing the first version: the replication section asked for arm counts that only the test section has (`hg_out/hg_run_console_crashed.txt`). The print line was fixed and the run restarted; its first version is identical to the stopped attempt line by line. No rule or computation changed. **All four Buried:**
  - **HG5-TGT 1 of 6:** 2,307 trades (1,312 / 444 / 551), -$43 a trade net (-$12 before costs), PF 0.40; DEV t -15.18, VAL PF 0.32, control 3.4th percentile, holdout -$22,361. Only the trade count passes.
  - **HG5-TRL 1 of 6:** 2,360 trades, -$45 a trade (-$14 before costs), PF 0.44; DEV t -13.33, VAL PF 0.41, control 75.4th, holdout -$20,996.
  - **HG60-TGT 2 of 6:** 307 trades (173 / 61 / 73), -$43 a trade (-$12 before costs), PF 0.73; DEV t -2.56, VAL PF 0.35, control 47.6th, without the 10 best -$22,611; the holdout +$2,505 (PF 1.18) passes.
  - **HG60-TRL 1 of 6:** 318 trades, -$109 a trade (-$78 before costs), PF 0.48; DEV t -3.46, VAL PF 0.33, control 0.0th percentile, holdout -$9,590.
  - Rule 3 (72, 74, 18, 24 trades flagged) changes no verdict. Before costs every version loses in ADR units over the ten years (-1.1% to -7.2% of the ADR a trade).
  - Funnel (5-minute TGT, 2010-2019): 12,925 arms, 10,237 setups, 6,504 unfilled, 1,673 no room, 2,060 first trades, 247 re-entries. The strict reading (ADX still rising at the touch) is 6-9% of setups.
  - **Replication 2020-2026 (descriptive):** every version negative: -$39, -$32, -$83, -$248 a trade; control percentiles 58.2, 96.0, 27.0, 0.0.
  - `node hg_run.js --reproduce` gave identical outputs.
- 2026-11-18: published as /posts/holy-grail-trading-setup-es-futures/ on 18 Nov 2026 (the owner asked for the article on 2026-11-18: "Da, scrie-l"; deployed with the owner's explicit agreement). The article cites no other site's test of the setup. Article notes, descriptive only: the drawdowns, the best ten trades, the long and short totals and the monthly equity were computed from the trade logs by `build_hg_post.js` (written to `hg_out/hg_site.json` and `hg_equity.json`; the run's own files are unchanged).
