PASS synthetic 1: events golden@3, death@6, golden@10 PASS synthetic 1 long-only: 2 trades, entry 14 -> 8 net -330.76, then open at end 12.25 -> 11.75 net -30.76 PASS synthetic 1 long-short: 3 trades (-330.76, short 8 -> 12 net -230.76, long open -30.76) PASS synthetic 1: gross = price move only PASS synthetic 1 gold: net points -6.30, percent -45.0, financing 3 days at 3%/yr PASS synthetic 2 (first-state rule): events death@6, golden@10 only PASS synthetic 2 long-only: one trade, opened on the first observed golden cross (14, open at end, net -30.76) PASS synthetic 2 long-short: first position is the short opened by the death cross (9 -> 14, net -280.76), then long open -30.76 PASS roll cost: trade held across 2021-03-11 pays one extra $30.76 (net -361.52) PASS roll dates: 2021 = Mar 11, Jun 10, Sep 9, Dec 9 PASS roll counting: entered the roll day session -> charged; exit fill on the roll day -> not charged PASS worst open loss: spike of 5 points inside the trade = $250 (the exit bar, 6 points away, is excluded) PASS EMA(3) of 1..5 = [NaN, NaN, 2, 3, 4] PASS SMA(3) of 1..5 = [NaN, NaN, 2, 3, 4] PASS state series: shift 0 reproduces the real events Golden cross engine self-test. Run 2026-10-08T05:16:55.440Z Real data (no results printed): PASS ES: day keys strictly increasing, no duplicate day PASS ES: daily bars identical to the independent construction (1742 days; 0 short days dropped) PASS ES: 245-262 session days (counted days plus data-hole days) in every full calendar year - years 2021-2025 PASS ES: the fill minute directly follows the signal day's last bar (by construction i1+1 < n) PASS ES GC-L-SMA: engine = independent reference, trade by trade PASS ES GC-LS-SMA: engine = independent reference, trade by trade PASS ES GC-L-EMA: engine = independent reference, trade by trade PASS ES GC-LS-EMA: engine = independent reference, trade by trade PASS ES: rolling SMA(50) and SMA(200) match a naive recomputation to 1e-9 - max diff 0.0e+0 PASS ES: rolling EMA(50) and EMA(200) match a naive recomputation to 1e-9 - max diff 0.0e+0 (ES: days where the two averages are exactly equal after the warm-up: 0/0/0/0 for the four variants; the spec's >= / <= rule handles them) PASS XAUUSD: day keys strictly increasing, no duplicate day PASS XAUUSD: daily bars identical to the independent construction (5702 days; 34 short days dropped) PASS XAUUSD: 245-262 session days (counted days plus data-hole days) in every full calendar year - years 2005-2025 (XAUUSD: data holes, days with fewer than 30 one-minute bars, not counted as days: 2006-01-02; 2006-07-04; 2010-12-20 .. 2011-01-13; 2012-03-06 .. 2012-03-22) PASS XAUUSD: the fill minute directly follows the signal day's last bar (by construction i1+1 < n) PASS XAUUSD GC-L-SMA: engine = independent reference, trade by trade PASS XAUUSD GC-LS-SMA: engine = independent reference, trade by trade PASS XAUUSD GC-L-EMA: engine = independent reference, trade by trade PASS XAUUSD GC-LS-EMA: engine = independent reference, trade by trade PASS XAUUSD: rolling SMA(50) and SMA(200) match a naive recomputation to 1e-9 - max diff 1.0e-11 PASS XAUUSD: rolling EMA(50) and EMA(200) match a naive recomputation to 1e-9 - max diff 0.0e+0 (XAUUSD: days where the two averages are exactly equal after the warm-up: 0/0/0/0 for the four variants; the spec's >= / <= rule handles them) SELF-TEST PASSED: every check passed (4 s). ma_run.js may now be pointed at the data. PASSED 2026-10-08T05:16:59.717Z