# Turtle Trading (System 1 and System 2) on daily gold - specification (RIP Backtest protocol v1.0 plus the 8 Oct 2026 rules)

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

## What was looked at before, and why this test was chosen
- **Chosen by the owner** on 2026-10-09 (Turtle Trading), with the market (gold, daily bars, 2004-2026) and the variants (System 1 and System 2, each with one unit and with pyramiding) chosen from proposals the same day.
- Earlier tests on this gold series: daily golden cross (4 variants, Inconclusive: too few trades), 1-hour golden cross (one variant passed, later set to Inconclusive by a data check), EMA 9/20 on 15-minute and 1-hour bars, the 30-minute opening-range breakout, and unprotocolled tests. **Trend-following rules have done better than others on gold**; this test was chosen knowing that, which weakens a positive result, and the article will say so. The 20-bar / 10-bar Donchian breakout (the core of System 1) was tested on **ES 1-hour bars**, not on gold or daily bars.
- No Turtle number on gold was looked at.

## Instrument and data
- **XAUUSD** on the IC Markets MetaTrader 4 demo server, a spot gold CFD in US dollars per ounce, not a futures contract. Results per ounce and in R.
- **Data:** the terminal's 1-minute bid history (`XAUUSD1.hst`) from the first bar of 2004 to **2026-10-07 16:57 New York**, the same part of the file as the published gold studies (`gx_lib.loadGold({ fix: false })`, SHA-256 of that part in `mt4_prefix_hashes.json`).
- **Daily bars:** a trading day runs from 17:00 to 17:00 New York (the gold market's daily break), as in the daily golden cross test (`ma_lib.dayKey`); Saturday and Sunday minutes belong to Monday. A day is built from the minutes that exist; days with fewer than 30 minutes are skipped for signals (they were listed in the golden cross test).
- **Clock:** the clock audit of 9 Oct 2026 found the file's time stamps one hour early in many weeks of 2004-2010. Daily bars split at gold's daily break are almost unaffected (the daily golden cross changed by less than 4 percentage points, no gate changed). **Check before the results are shown:** the run is repeated on the corrected copy of the file (`clock_audit_fix.js`); every gate and verdict must be the same, or the difference is reported and the run is treated under rule 3.
- **Holes (rule 3):** the gap audit of the gold file (`data_holes_xau.json`) is used; trades open across a suspect or unclear gap are counted, and every gate and verdict is recomputed without them; a changed verdict becomes Inconclusive.

## Rules (the original Turtle rules, as published by the Turtles; fixed here as written)
All levels are computed at the close of a trading day from completed days and act during the next day; orders execute on the 1-minute bars of that day.
- **N:** the 20-day average true range, N = (19 x previous N + TR) / 20, seeded with the simple average of the first 20 true ranges. TR = max(high - low, |high - previous close|, |low - previous close|) of the daily bars.
- **System 1 (S1) entry:** buy when price trades one tick ($0.01) above the highest high of the previous **20** days; sell short one tick below the lowest low of the previous 20 days. **Skip rule:** a S1 breakout is ignored if the last S1 breakout (long or short, taken or not) would have been a winning trade under these rules; it is taken if that breakout would have lost (by stop or by exit). **Failsafe:** if S1 skipped a breakout, a breakout of the previous **55** days in the same direction is taken while no position is open, so a big trend is not missed.
- **System 2 (S2) entry:** buy one tick above the highest high of the previous **55** days; sell short one tick below the lowest low of the previous 55 days. Every breakout is taken.
- **Fill:** at the breakout level, or at the open of the first minute of the day if price opens beyond it (a gap). If a day's minutes cross both the long and the short level, the side touched first is taken.
- **Stop:** **2N** from the entry price (N at the previous close). Inside a minute the stop is taken before any other exit; a stop gapped through fills at the open of that minute.
- **Exit:** S1 longs exit one tick below the lowest low of the previous **10** days (shorts: above the 10-day high); S2 longs exit below the **20**-day low (shorts: above the 20-day high). Exit at the level, or at the open if gapped.
- **One unit (1U variants):** one position of one unit; no adding.
- **Pyramiding (4U variants):** after the first unit, one more unit is added each time price moves **N/2** beyond the previous unit's fill (N fixed at the first entry), up to **4 units**; each addition moves the stops of all units to 2N from the latest unit's fill. The exit closes all units. No new entry while a position is open.
- **Size and R:** each unit is the same size (the original sizes a unit by N; with results in R that sizing is already built in). **R = 2N at the first entry**, the risk of one unit; a trade's result in R is the sum over its units of (exit - fill) in dollars per ounce, divided by that R. Results also in dollars per ounce per unit.
- **Four variants (the only ones tested):** **TT-S1-1U, TT-S1-4U, TT-S2-1U, TT-S2-4U**, long and short.
- A position open on the last bar is closed at its close and flagged. Positions are held over weekends and holidays.

## Costs
- **Baseline:** **$0.30 per ounce per round trip per unit** for spread and commission, as in every gold test on the site; slippage zero beyond gaps, which is optimistic and stated.
- Turtle positions last weeks, so the overnight financing matters. As in the EMA 9/20 gold test, two scenarios are reported next to the baseline: **A**, 3% a year of the entry price per calendar day held, charged to longs and shorts alike; **B**, today's IC Markets swap (long -$0.56282, short +$0.39136 per ounce per night, Wednesday counting three nights), applied to all years: **not a historical swap**. The verdict is that of the baseline.

## Periods and data use
- **Periods (by first entry date):** development 2004 .. 2012; validation 2013 .. 2019; holdout 2020 .. 2026-10-07. **None is fresh:** all were used by the earlier gold tests; the holdout is reported as already used.

## Gates and verdicts
Six gates per variant: validation profit factor >= 1.2; at least 50 trades in each period; development t >= **2.0** (four variants are tried; the 2.5 bar applies above four); 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; otherwise Buried or Survivor. **Expected weak point, stated now:** S2 makes few trades (55-day breakouts), so it may fail the 50-trades-per-period gate.

## Matched control
A **time-shifted entry control**: the real entries of each variant (day and direction) are moved together by one random offset of at least 5% of the number of days (circularly); on each shifted day the position is opened at the first minute of the day in the same direction, with the same N, stop, exits, pyramiding, costs and one-position rule as the real variant. It asks whether the breakout timing adds anything over entering on other days with the same exits. 500 runs, fixed seeds 1000 + run, the same offsets for all four variants. Statistic: average net R per trade.

## Engine and self-test (before the run)
A new engine (`tt_lib.js`) and a self-test that must pass before any result is printed:
1. Hand-worked cases: N and its seed; a 20-day and a 55-day breakout filled at the level and at a gapped open; the skip rule after a winning and after a losing breakout (taken or not); the failsafe 55-day entry; the 2N stop, also in the entry minute and gapped through; the 10-day and 20-day exits; pyramiding to 4 units with the stops moved; a day that crosses both levels; costs per unit; R and the result in R.
2. The daily bars and N checked against a naive recomputation on the real data.
3. An **independent re-implementation** matched trade by trade for all four variants on the real data.
4. The control machinery at offset 0, fed with the real entry days, reproduces the real entries.

## Before the article
The results go to the owner first: all four variants, every gate, drawdown on closed trades and including open positions, the clock check, the hole check, long and short separately, the cost scenarios. The article (one test, one market) is built only after that and published only with the owner's agreement.

## Always reported
Win rate with its 95% Wilson interval, how trades ended (stop, exit, end of data), average days held, units added, gross and cost per trade in R, long and short separately, drawdown on closed trades and including open losses, results by year, buy and hold in the same dollars, the share of the result from the 10 best trades.

## 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 original parameters only.
