# Inside Bar Breakout on EURUSD, daily bars - 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)**. No daily bar, inside bar, signal or trade of this test has been computed. Looked at before writing: the first and last bar and the bar count of the EURUSD file (2004-01-01 to 2026-09-28, 8.3 million minutes). Once frozen, any change of a rule is documented and treated as a separate test; bugs may be fixed.

## Why this test, and where the rules come from
- **Chosen by the owner** on 2026-10-21 from four EURUSD proposals ("1").
- **The idea:** an inside bar is a daily candle whose high and low are both inside the previous candle (the "mother bar"): the market has paused. A break of the mother bar is taken as the start of the next move. It is the best-known "price action" setup, taught for forex on daily charts. Write-ups agree on the core (stop orders beyond the mother bar's high and low, the stop at the other side) and differ on filters (trade only with the trend) and targets (often 2R or "the next level"). We fix one common reading here, with and without a trend filter, and do not try others after the result.
- **Looked at before on the site:** EURUSD in the FX study (six indicator strategies on hourly bars) and five other EURUSD tests (golden cross, Turtle, Fibonacci 61.8, Stochastic RSI with MACD, Ichimoku), all buried; the London breakout on GBPUSD (21 Oct 2026). No candle-pattern test on EURUSD.

## Instrument and data
- **EURUSD**, IC Markets MT4 demo, 1-minute bid history **2004-01-01 to 2026-09-28** (`fx_data.loadFx`), New York wall clock, close stamps.
- **Daily bars:** the forex day, **17:00 to 17:00 New York** (the server's midnight), Monday to Friday; the Sunday-evening minutes belong to Monday's bar. Built from the minutes; a day with fewer than 600 minutes is not a bar (holidays).
- **Clock check (before the run):** the week-open hour of every week in the clock-change windows, as for GBPUSD (lb_clock.js); weeks opening in the 16:00 hour would be shifted. **Holes (rule 3):** the same gap audit as GBPUSD, written to `data_holes_eurusd.json`.

## Rules
- **Inside bar:** day k with high[k] < high[k-1] and low[k] > low[k-1] (strictly inside; equal highs or lows do not count). Day k-1 is the mother bar.
- **Orders for the next day only (day k+1):** a buy stop **1 pip above** the mother bar's high and a sell stop **1 pip below** its low. The first one touched is filled (at the level, or at the minute's open if it gaps beyond); the other is cancelled. If neither is touched during day k+1, both are cancelled. If one minute touches both, the side nearer that minute's open is taken and it is stopped in that minute (as in the London breakout test).
- **Stop:** 1 pip beyond the other side of the mother bar. **R** = fill to stop, in pips.
- **Exits:** **IB-1R** target 1R; **IB-2R** target 2R; **IB-2R-T** target 2R with a trend filter: longs only if the close of the inside bar (day k) is above its 50-day simple moving average of daily closes, shorts only if below (the other order is not placed). All three: a trade still open at the close of the **20th trading day** after entry closes there (our addition, so that no trade lasts months).
- **One position at a time;** inside bars that form while a trade is open are ignored. Inside stop and target in the same minute: the stop first; in the entry minute both fill at their level.

## Costs and financing
- **1.5 pips per round trip** (as for GBPUSD; stop orders slip), shown also at 1.0 and 2.5 pips; the verdict is that of 1.5.
- **Overnight swap** is not in the base result: trades last days, and EURUSD swaps changed sign over these years with interest rates. A stress scenario charges **0.5 pip per night** held, longs and shorts alike (Wednesday counting three).

## Results, periods, gates, control
- **Units:** R per trade and pips. Also reported: inside bars per year, R in pips, long and short, by year, how trades ended, holding days.
- **Periods (by entry date):** development 2004 .. 2012; validation 2013 .. 2019; holdout 2020 .. 2026-09-28 (**already used** by the FX study and the earlier EURUSD tests).
- **Six gates per variant:** validation profit factor >= 1.2; at least 50 trades in each period; development **t >= 2.0** (three variants of a strategy not tested before on the site); 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 whole trading days (at least 5% of them), to the same time of day on the new day, same direction, same R in pips, same exits and costs. 500 runs, seeds 1000 + run. Statistic: average net R per trade.

## Engine and self-test (before the run)
New engine `ib_lib.js`, independent re-implementation `ib_ref.js`, `ib_selftest.js` that must pass before any result is printed: daily bars on the 17:00 boundary (a Sunday evening, a holiday), inside bars including equal highs or lows, the next-day-only orders and the cancelled side, both levels in one minute, gaps, the trend filter, stop before target, the 20-day exit, costs and the swap scenario; the reference matched trade by trade on the real data for all three variants; the control at offset 0 entering at the real minutes.

## Before the article
Results go to the owner first: all three variants, every gate, long and short, by year. One article, published only with the owner's agreement. Working title for search: "Inside Bar Trading Strategy Backtest: EURUSD Daily, 22 Years".

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