# H1 Open Trap on XAUUSD, 1-minute data - specification (RIP Backtest protocol v1.0 plus the 8 Oct 2026 rules)

Specification written and **frozen 2026-10-21 (approved by the owner the same day, draft 1 unchanged; the owner asked only what "end of the broker day" means: 00:00 server = 17:00 New York = midnight in Romania)**, before any trap, 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:** their own MT4 indicator `H1_Open_Trap_Dashboard.mq4` (reviewed 19 Oct; read again 21 Oct, the owner's file is never edited). Owner's choices on 21 Oct: **trap signals only** (no continuation or recovery), **the indicator's default settings**, stop at -1R, targets +1R / +2R / +3R as three separate variants, a trailing stop after +1R, the name **H1 Open Trap**.
- The indicator draws no profit target (its panel only moves the stop to break-even +1 at +$5 and to +5 at +$10); the exits below are the owner's, written before any result.
- Earlier tests on this gold file: daily and 1-hour golden crosses, EMA 9/20, ORB, Turtle, noise area, RSI 30/70, TTM Squeeze, WaveTrend, head and shoulders. **No H1-open level has been computed on the site.**

## Instrument and data
- **XAUUSD**, IC Markets MT4 demo, 1-minute bid history 2004 .. **2026-10-07 16:57 New York**, loaded with **`gx_lib.loadGold({ fix: true })`** (clock corrected), because these rules depend on the time of day. The clock fix is the one used in the EMA 9/20 test.
- **Broker day** = 00:00 server time = **17:00 New York** (the server runs at New York + 7 h all year). H1 bars and M15 bars are cut on the server clock from the minutes that exist.
- **Holes (rule 3):** `data_holes_xau.json`; trades open across a suspect or unclear gap are counted, and every gate and verdict is recomputed without them; a changed verdict becomes Inconclusive.

## The trap (the indicator's `EvaluateTraps`, default inputs)
Per broker day, minute by minute:
1. **Lines:** highest and lowest **H1 open** of the broker day so far (updated when each new H1 bar opens). A new higher open resets the sell setup; a new lower open resets the buy setup.
2. **Trading window:** signals only in minutes from **06:00 to 24:00 server** (23:00 .. 17:00 New York). Minutes outside still update the day's high and low.
3. **Arming (trigger M15, at least 2 H1 bars in the day):** at the open of each M15 bar, a **sell** is armed if that open is above the highest H1 open and not above the day's high so far (price is in the "interest area" above the line); a **buy** is armed if the open is below the lowest H1 open and not below the day's low. Stop = the day's high (sell) / low (buy) before that bar, buffer 0.
4. **Reset:** an armed sell is cancelled if price makes a new day high beyond the armed extreme; an armed buy if price makes a new day low.
5. **Signal (aggressive mode):** an armed sell triggers when a minute's low touches the line; an armed buy when a minute's high touches the line. **Entry price = the line.**
6. **Blocking filters** (`BlockHighRiskSignals = true`): a signal is skipped if
   - **sell** and price is at or above the **previous day's high** (buy: at or below the previous day's low); previous day = the last broker day with at least 240 minutes, looking back up to 7 days;
   - more than **90 minutes** passed since arming;
   - **2 consecutive M15 closes** beyond the line (above for a sell, below for a buy) between arming and the signal;
   - the **EMA 9/20/50/200 stack on M15** is against the trade, **unless** it is the only reason and the setup is a classic trap (extreme beyond the line). With the default inputs every armed setup is a classic trap, so **the EMA filter never blocks a trap**; it is kept exactly as coded and this is stated in the article.
7. **At most 3 trap signals per day** (the 4th and later are ignored; `SkipFirstTrapsPerDay = 0`).

**Look-ahead fixes (the indicator reads them on a live chart, where they are known; in a backtest they would see the future):** the previous-day test uses the close of the **last completed minute** before the signal minute (the indicator uses the close of the signal minute itself); the EMA stack uses the **last completed M15 bar**. Both are disclosed.

## Rules (trades)
- **Entry:** at the line price in the signal minute (a resting order at the line), sell for SELL_HIGH_OPEN, buy for BUY_LOW_OPEN. **Long and short.** **One position at a time:** a signal while a trade is open is not taken (it still counts toward the indicator's 3 per day, as on the panel).
- **R** = |entry - stop| in dollars per ounce, the stop being the day's extreme from the trap (this is the -1R stop).
- **Three variants:**
  - **HOT-1R:** stop -1R, target +1R.
  - **HOT-2R:** stop -1R, target +2R; once price reaches **+1R**, a **trailing stop $2.00 per ounce** behind the best price since entry (20 pips at 0.10 = $20 at 0.10 lot, as the owner set it), never looser than the original stop.
  - **HOT-3R:** as HOT-2R with target +3R.
- **Time exit:** any trade still open is closed at the **end of the broker day** (last minute before 17:00 New York), at that minute's close. The owner's rules give no time exit; this one is ours, so that no trade is held across the daily break.
- **Order inside a minute** (1-minute bars only): in the entry minute, if the bar also reaches the stop beyond the entry, the trade is counted as **stopped**; in any minute where both the stop and the target are inside the bar, the **stop is taken first**; the trailing stop moves only on completed minutes (it is updated with a minute's high/low after that minute is checked against the old stop). Conservative, stated.

## Costs
- **Baseline:** $0.30 per ounce per round trip, as in every gold test on the site; slippage zero on the stop and target, which is optimistic and stated. No financing (no trade crosses the daily break).
- Reported: the cost as a share of the average R; R in dollars (median, and how many trades have R under $1).

## Periods, gates, control
- **Periods (by entry date):** development 2004 .. 2012; validation 2013 .. 2019; holdout 2020 .. 2026-10-07 (**already used** by earlier gold tests).
- **Six gates per variant:** validation profit factor >= 1.2; at least 50 trades in each period; development **t >= 2.0**; 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 trading days, to the same server time on the new day, same direction, **the same R in dollars**, the same exit rule, costs and one-position rule. 500 runs, seeds 1000 + run. Statistic: average net R per trade. It asks whether the trap picks better moments than the same trades placed on other days.

## Engine and self-test (before the run)
New engine `h1ot_lib.js` (no other engine touched) and `h1ot_selftest.js`, which must pass before any result is printed:
1. Hand-worked days: lines and their resets, the window, arming at M15 opens only, the reset on a new extreme, the touch, each blocking filter, the 3-per-day cap, one position at a time; exits at -1R, +1R/+2R/+3R, the trailing stop, the time exit, the order-inside-a-minute rules, costs.
2. An **independent re-implementation** (`h1ot_ref.js`) matched signal by signal and trade by trade on the real data for all three variants.
3. The control at offset 0 reproduces the real trades.
4. **Spot check against the indicator:** a few days chosen at random from 2026 compared with the indicator's own signals in MT4 (HistoricalReviewMode), with the look-ahead differences above expected and listed.

## Before the article
Results go to the owner first: all three variants, every gate, long and short separately, by year, by hour, the R distribution, how long trades last, the cost per trade against the gross, the hole check. One article, published only with the owner's agreement.

## Reading the result
"Buried" or "Inconclusive" mean a statistically convincing edge was not demonstrated; neither is proof that none exists. One market, one broker's demo history, the default settings only.
