# Golden cross (50 / 200) on 1-hour bars, 24 hours, with and without a stop and targets - frozen specification (RIP Backtest protocol v1.0 plus the 8 Oct 2026 rules)

Specification written **2026-10-08, before any 1-hour average, cross, signal or trade of this test was computed.** What was looked at before writing it: the daily golden cross test (published; its
results are in `ma_out/`), the code of the existing hourly engine (`hourly_lib.js`, `rsi2_protocol.js`), and the author's Trident test scripts only to see how "R" and "TP1 / TP2 / TP3" were defined there. No
hourly moving average, cross count, trade or result was looked at. Bugs may be fixed after the run; rules may not. If the engine fails its self-test (below), nothing is run.

## What was asked for
The same 50/200 moving-average cross as the daily test, on **1-hour bars**, trading **all sessions, 24 hours**, **with and without a stop loss and take profits**: stop 1 R, TP1 at 1 R, TP2 at 2 R, TP3 at 3 R.
The author uses R as in the Trident tests: **1 R = the distance from the fill to the stop**. TP1, TP2 and TP3 are tested as three separate exit rules ("close everything at that target if it is touched, otherwise at the
stop"), and "1/3 each" (a third of the position at each target, untouched thirds at the stop) is the exact average of the three.

## Rules
- Fast = 50-bar, slow = 200-bar **simple** moving average of the 1-hour closes (bars as built below; the count is bars, not hours of the clock). Exponential averages are not tested here.
- **Golden cross** at the close of bar k: fast[k] > slow[k] and fast[k-1] <= slow[k-1]. **Death cross**: fast[k] < slow[k] and fast[k-1] >= slow[k-1]. Signals start on the first bar both averages exist.
- **Entries happen only on a cross** (never on the state): a golden cross opens a long; in the long-short versions a death cross opens a short. Fill: the **open of the first 1-minute bar after the signal bar**, plus slippage.
- **All sessions, 24 hours**: no time-of-day filter, no session filter. The averages and the signals use every hourly bar, including the overnight and Asian hours. **Positions are held over weekends and holidays** (the daily test did the same);
  this is a deliberate difference from the other hourly tests on this site, which close every position on Friday afternoon, because a flat-on-Friday rule would cut a slow trend rule into one-week pieces.
- If the averages already stood in the golden state when they first existed, no trade opens until the next cross (a position needs an observed cross).
- **After a stop or a target the position stays flat until the next cross**: there is no re-entry in the same state.
- Exit on the **opposite cross** (a golden cross closes a short, a death cross closes a long) at the open of the first 1-minute bar after the signal bar. In the long-short versions the opposite cross also opens the new position at that same fill.
  A position still open on the last bar is closed at that bar's close and flagged "open at end of data".
- **R (the risk unit)** = 1.5 x ATR(14) of the 1-hour bars at the signal bar, in price points. The request did not give a size for R; this is the author's choice, taken from the 1.5 ATR stop used in this site's earlier
  stop-and-target variants, and it is fixed here. A different size would be a different variant and would be counted as one. The stop is placed at the fill price minus (long) or plus (short) 1 R; targets at the fill price plus (long) or minus (short) the multiple times R.
- Stop and target execution as in the other hourly tests: checked on every 1-minute bar from the entry minute; the **stop wins a tie** within a minute; a level that price gaps through fills at that minute's open; slippage on every fill including stops and targets.

## Markets and data
- **ES**: E-mini S&P 500 futures, back-adjusted continuous 1-minute file (`ES_1min.csv`), 2020-01-01 to 2026-09-25. $50 per point.
- **Gold**: spot XAUUSD from the IC Markets MT4 demo-server 1-minute history, 2004 to October 2026, converted to New York time (server = New York + 7 hours). The history has holes (see the daily spec); trades whose entry or exit minute falls on a hole day are flagged.
- 1-hour bars are built from the 1-minute bars exactly as in every other hourly test: bar time = close time on the New York clock, one bar per clock hour.

## Variants (declared up front; the ONLY ones tested): 12 per market, 24 in total
Each of the two position modes **L** (long only) and **LS** (long and short) with six exit rules:
- **N**: no stop, no target; exit on the opposite cross (the plain golden cross rule on hourly bars).
- **S**: stop 1 R only; exit on the stop or the opposite cross.
- **T1**, **T2**, **T3**: stop 1 R and one target at 1 R, 2 R or 3 R; exit on the stop, the target or the opposite cross.
- **T123**: stop 1 R; a third of the position closes at 1 R, a third at 2 R, a third at 3 R; any third not filled by a target closes at the stop or on the opposite cross. The stop is not moved to break even.
  T123 is computed exactly as the average of T1, T2 and T3 on the same entries (the three share every entry, because entries happen only on crosses). It is counted as a variant; each third pays the costs of one lot.
Names: `GH-L-N`, `GH-LS-T2` and so on, prefixed by `ES-` or `XAU-` in the files. No other parameters will be tried after seeing results (no other averages, no other R size, no break-even move, no re-entry rule).

## Costs
- **ES**: commission $5.76 per round trip plus one tick (0.25 point) of slippage on every fill = $30.76 per trade, as in all the ES tests; the same $30.76 for each quarterly roll a position is held through
  (the second Thursday of March, June, September and December, charged if the position is open at 17:00 New York on that date).
- **Gold**: $0.30 per ounce per round trip, as in the gold test, no slippage line. **Overnight financing is not in the baseline**; reported as a sensitivity: 3% a year of the entry price for every calendar day held (an assumption). The verdict uses the baseline.

## Units
**Net R per trade** (net result in points divided by R in points), non-compounded, for both markets, so the stop-and-target and no-stop variants are comparable. Dollars per contract (ES) and dollars per ounce (gold) are reported next to it.
R is defined for the N variants too (it is just not used for an order).

## Periods (by entry date)
ES: Development 2020-01-01 .. 2023-12-31; Validation 2024-01-01 .. 2025-03-31; Holdout 2025-04-01 .. end. Gold: Development 2004-01-01 .. 2012-12-31; Validation 2013-01-01 .. 2019-12-31; Holdout 2020-01-01 .. end.
**The holdout is not clean on either market** (the same data appeared in earlier tests, including the daily golden cross); it is reported and flagged as used.

## Gates (per variant and market)
1. Profit factor >= 1.2 in validation. 2. At least 50 trades in each period. 3. Development t-statistic >= **2.5** (more than four variants are tried). 4. Above the 95th percentile of 500 random runs of the matched control (average net R per trade, full sample).
5. Positive after removing the 10 best trades. 6. Holdout net positive (flagged used). All six are printed for every variant.

## Sample-size rule (as in the daily test)
A variant with **fewer than 30 trades** in the full sample gets the verdict **Inconclusive** whatever its gates show. With 30 or more: Buried (any gate failed) or Survivor (all six). The 24 results share entries, so they are not 24 independent looks; they are all counted as tried.

## Matched random control (rule of 8 Oct 2026: matched on the signal's entry state)
The real state series (fast above slow = +1, below = -1, on every bar both averages exist) is circularly shifted by a random offset of at least 5% of its length and applied to the real prices, with the same entry rules,
the same exits (stop, targets, opposite cross), the same R computed from the real ATR at the shifted signal bar, the same costs and the same first-state rule. Same shifts for every variant of a market; 500 runs; fixed seeds (1000 + run number);
runs with no trade excluded. The statistic is the average net R per trade. This keeps the number, spacing and length of the up and down episodes and moves them to random dates.

## Always reported, whatever the verdict
Win rate with its 95% Wilson interval, average winner and loser in R, how the trades ended (stop, target, opposite cross, still open), average bars held, time in market, long and short sides separately, results by period, drawdown on closed trades and
including open losses (the worst open loss inside a trade, in R), cost per trade in R next to the gross result per trade, the gold financing sensitivity, and the same-market comparison with the daily golden cross result.

## Before anything is run (self-test)
`gh_selftest.js` must pass before `gh_run.js` may touch the data: (1) hand-worked synthetic series for the stop, a target, a stop and a target in the same minute (the stop wins), a gap through a stop, an exit on the opposite cross at the next open,
a long-short reversal, the long-only version ignoring a death cross, no re-entry after a stop, the first-state rule, the roll charge, the gold cost and T123 as the average of T1, T2 and T3; (2) an **independent re-implementation** (naive averages, a bar-by-bar and minute-by-minute loop)
must match the engine trade by trade on the real data for all 24 variants; (3) the shifted-state control with shift 0 must reproduce the real events. No result is printed by the self-test.

### Self-test finding (recorded 2026-10-08, before the run)
The first self-test run found one failure: on two ES bars the two averages are exactly equal (both at a crossing), and the state series used by the control (+1 if fast > slow, else -1) flipped one bar earlier than the cross rule
(which needs fast > slow strictly) fires. The control's state definition was corrected: on an exact-equality bar the previous state is kept, so the state flips on the same bar as the cross rule. The cross rule itself, and every entry, exit and cost rule, is unchanged;
the daily test is unaffected (it has no equality bars). No result had been computed. The independent re-implementation already agreed with the engine on all 24 variants.

### Run log and additions after the first run (2026-10-08)
`gh_run.js` was run with the rules above; the first output showed one Survivor (gold, long only, no stop, no target) and 23 Buried. Nothing was changed because of that. After seeing it, the report was extended with **descriptive** items only, none of which touches a gate or a verdict:
buy and hold in the same dollar units, the worst peak-to-trough of the equity marked to market at every hourly close, the compounded growth of the gold trades, and (in the article, computed from the published trade logs) the survivor's results in percent of the entry price and in dollars per ounce
instead of R, by calendar year, with a higher cost per trade, and its ten best trades. The re-run reproduced every earlier line exactly.
The survivor passes gate 3 (development t >= 2.5) in the unit fixed in advance (R: 2.65). In percent of the entry price the same trades give 2.37 and in dollars per ounce 1.90, so the margin is narrow and depends on the unit. This is reported in the article.

### Numerical note added while extending the engine to EUR/USD (2026-10-08, before the EUR/USD run; the ES/gold article had not been published)
On EUR/USD the independent re-implementation disagreed with the engine on a few cross bars: the two averages are mathematically equal on those bars and floating-point noise (about 1e-14) broke the tie differently in the two. The cross rule is unchanged (golden: fast > slow and previously fast <= slow; death the reverse),
but a difference between the averages below 1e-10 is now treated as an exact tie (a real difference is at least about 5e-8 on 5-decimal prices). ES results were reproduced exactly; gold gained one tie bar, which moved a few entries by one hour and changed some figures in the second decimal
(for example the survivor's financing sensitivity 541.69 -> 541.67 R; its net, gates and verdict are unchanged, and no verdict of any of the 24 results changed). The published results and the article use the corrected run.

## Reading the result
"Inconclusive" and "no proven edge" mean a statistically convincing edge was not demonstrated; neither is proof that none exists. R = 1.5 ATR is one choice of stop distance. ES is one back-adjusted futures series and gold one broker's spot history.

### Terminology note (added 2026-10-08, after outside review; no rule changed)
Where this specification says "matched random control", the benchmark of the 1-hour ES and gold test is a **circularly shifted state-series control**: the real up and down state series of the two averages is shifted by a random offset of at least 5% of its length and the same rules, prices and costs are applied (not a random-entry test). The ATR-based R, and with it every stop and target distance, is recomputed at the shifted signal time from the real prices.
