# EURUSD after a prior NYSE-session low in the last hour

One EUR 10,000 long-only EURUSD CFD transfer test, 2016–2025. The
[public Quantified Strategies article](https://quantifiedstrategies.substack.com/p/spy-sets-low-or-high-in-the-last)
(5 July 2024) supplies the SPY low-in-the-last-hour idea: buy the next opening
and exit at 11:30 New York. No short case is tested. This is a currency BID/M5
and NYSE-core-window adaptation, not replication of SPY returns or a full
24-hour FX daily-low strategy.

## Frozen protocol and calendar

`protocol.json` was frozen before counts/outcomes at
`2026-11-29T09:08:02.862140+00:00`. SHA-256:

`c72011d7e4e1d1dde51117660e525cdd121d727b4da93e9509cedfd39aad72f6`

The bundled [sessions.csv](sessions.csv) is a required Python **and MQL5**
dependency. Its immutable SHA-256 is:

`3cbbac4e5d20f5f2471fb476521a6106b6a6b3959e808dc380d86e3c4f10558d`

`sessions.manifest.json` records the XNYS calendar, exchange_calendars 4.13.3,
known NYSE holidays/exceptional closures, and DST/early-close anchors. The
calendar is exogenous, with actual America/New_York core opens/closes. The
engine consumes its timestamps, not future prices or an assumed fixed UTC
opening. The generator and separate calendar requirements are supplied for
inspection; the frozen CSV is used directly and needs no calendar package at
research runtime. Consult MQL5 notes for placing it in `MQL5/Files` and bundling
it with the tester. No replacement calendar was selected by returns.

## One long-only case

1. For the immediately preceding actual XNYS calendar session, take BID M5 bars
   fully contained in its core: start at/after open and start plus five minutes
   at/before actual close. Require **every aligned expected bar**, normally 78
   or 42 on early-close days. Missing coverage rejects the whole prior session;
   there is no imputation or partial-session fallback.
2. Find its minimum BID low on the literal five-decimal quote grid. Among exact
   ties select the **earliest** bar start. A later retest of an earlier low does
   not qualify. A distinct one-point lower price remains distinct.
3. Qualify only if that earliest minimum starts at or after actual prior close
   minus 60 minutes. The boundary follows early closes; it is not always 15:00.
4. Enter long at the next actual calendar session's **exact 09:30 New York M5
   OPEN**. If the quote is absent, consume/skip the whole candidate; never use a
   later quote to rescue it. Current execution-bar high/low/close selects no order.
5. Exit at the first opening quote at or after **11:30 on that same New York
   date**, retaining pending exits over gaps. The deadline is the calendar open
   plus two hours, not a timer restarted by a late fill. Exits process before
   any new entry. One position, no stop/profit target or other filter.

Start 2016 flat. The last actual 2015 calendar session may supply the first
2016 signal, but no 2015 position carries into the test. Current opening and
future exit quote availability never alter the prior price condition. Any
remaining position is forcibly closed at the last available 2025 close with
all costs and an explicit reason.

## EUR account and modeled execution

Use historical ask plus adverse 0.1 pip for a buy and bid minus 0.1 pip for a
sell. Commission is USD 3.50 per 100,000 EUR lot per side. Minimum/step is
0.01 lot, floored down, with at most current EUR cash in entry notional and
entry commission reserved:

`lots = floor(cashEUR / (100000 * actualEntryPrice / EURUSDask + 3.5 / EURUSDbid) / .01) * .01`

Actual entry includes slippage. Positive USD P&L converts at EURUSD ask;
negative P&L, fees and funding at bid. Long floating P&L marks BID. Entry
conversion quote age must be at most 900 seconds or the candidate is skipped;
there is no later fresh retry. Exit and valuation staleness are retained and
flagged. EURUSD itself supplies synchronized conversion quotes here.

**Funding is an assumed 5% annual debit** on absolute entry USD notional over
actual calendar seconds/365, not measured historical swap/carry. Cash earns
zero. This is CFD cash/P&L accounting, not a currency deposit return.

Primary buy-and-hold fixes initial quantity with the same entry cap/costs
from the first 2016 quote to the final 2025 close. Holding duration and financing
differ from the active case. A separately nested **ex-post exposure-scaled
passive diagnostic** linearly scales passive P&L/costs around EUR 10,000 by the
ratio of active/passive time-average absolute EUR notional, cash zero. It is
fractional/synthetic, not lot-deployable or another strategy case. Exposure
integrates previous observed marks across intervals, including gaps.

## Reproduce

Use Python 3.12 and the exact versions in `requirements.txt`:

```sh
python download_data.py --symbols EURUSD --period M5 --start-year 2015 --end-year 2025 --directory data --workers 3
python verify_data.py --require-raw
python -m unittest test_backtest -v
python backtest.py --data-dir data --calendar sessions.csv --out results
```

Preserve [EV Trading Labs](https://evtradelabs.com/data) attribution. These are
Dukascopy-derived distributor M5 aggregates, not independently reconciled bank
tick exports or actual FTMO quotes. Annual and processed input hashes are in
manifests. Full raw prices/caches are excluded from public downloads; scripts
recreate them subject to provider access. Cache reuse is not a new download.
See `data/README.md`, `data_quality.json` and calendar manifest for provenance.

## Outputs and limits

`session_inputs.csv` records every historical core, exact coverage/missing
starts, minimum low, earliest occurrence, tie count and actual last-hour
boundary. `session_candidates.csv` maps prior session to next calendar entry.
`session_events.csv` adds actual entry/exit timestamps and skip reasons. Trade
logs preserve prior low/coverage context, actual underlying bid/ask/fills,
conversion quotes, fees, funding and planned 11:30 deadline.

Both daily equity curves, trade/session logs, four PNG charts and summary
JSON/CSV are included. Local runs write both sampled M5 account curves. The
public package includes the strategy M5 curve; the large passive M5 curve is
omitted for size and regenerated by `backtest.py`. `run_environment.json`
records actual execution timestamps, versions and source/test/output hashes.

All closed-trade statistics are net of modeled costs. Daily Sharpe uses
calendar returns, sqrt365 and risk-free zero. Single-trade passive PF is not a
robust distribution metric. Daily bar-end values are assigned to the interval
just completed with a one-nanosecond boundary shift, retaining a final close
exactly at 2026-01-01 in 2025-12-31 daily equity. Sampled M5 drawdown omits the
tick path. Fixed 2016–2020 / 2021–2025 splits are retrospective diagnostics;
source publication lies within the later split, so neither is a pristine
prospective test.

FTMO records are continuous-account necessary conditions, not certified passes:
first sampled loss flags, maximum flat balance, first flat 10% target and
as-of-target best-day share of **total NET closed profit including losing days**.
A separate continuous 5% threshold is not fresh Verification. Missing-midnight
quotes require a first-quote Prague balance approximation. Actual swap history,
tick equity and all phase/restart/compliance conditions are not replayed.
An ending loss alone does not prove that no earlier target occurred.

Synthetic tests cover DST, early closes, complete grids, exact/earliest ties,
last-hour boundaries, exact-open skips, delayed exits, causal signals and EUR
accounting. `INDEPENDENT_QA.md` records the separate raw-data audit when complete.
MQL5 is supplied as source; no terminal compilation or native MT5 results are
implied. Original software is MIT licensed; articles, data and dependencies
retain their own terms.
