The rules tested
The strategy buys EUR/USD when the 14-period RSI climbs back above 30, and sells when it falls back below 70. Stop loss at 1.5 ATR, take profit at 1.5 ATR, 1% of the account at risk per trade, on 4-hour bars.
- Instrument
- EUR/USD
- Timeframe
- 4 hours (H4)
- Entry
- 14-bar RSI, levels 30 and 70, buy when it climbs back above the lower level, sell when it falls back below the upper level
- Filters
- none
- Stop loss
- 1.5 times the 14-bar ATR
- Take profit
- 1.5 times the 14-bar ATR
- Other exits
- none
- Risk per trade
- 1% of the virtual account, position size set from the stop distance
- Costs
- spread actually recorded hour by hour, slippage of half a spread on every stop, no commission; swaps not included
- Period tested
- from August 1, 2022 to September 25, 2026
The button opens the lab with exactly these settings: change one, run it again and compare.
What happens at midnight
Every day at midnight server time (5 p.m. in New York), the currency market rolls from one value date to the next. During the first minute the broker keeps publishing quotes but refuses orders, and spreads are at their widest of the day. At the first price where an order is accepted again, the spread is still far above its usual level. Averaged over the 1,078 days in the history:
| Instrument | First accepted price after midnight (pips) | Other hours (pips) |
|---|---|---|
| EUR/USD | 7.2 | 1.3 |
| GBP/USD | 13.6 | 1.5 |
| USD/JPY | 10.6 | 1.5 |
The prices shown during the refused minute raise a second problem: on EUR/USD, on roughly one day in three (34% of days), they stray more than half a pip outside the range where orders could actually be filled that hour. Gold (XAUUSD) is a different case: its trading session closes at midnight and only reopens at 1 a.m.
The test: a 14-period RSI on four-hour bars
To measure the effect on a backtest, we took a textbook rule, the 14-period RSI read as a move back from the 30 and 70 levels, on four-hour bars. Four hours is no accident: one bar in six starts at midnight, and a signal read when the 8 p.m. bar closes is filled at the first price of the next bar, right after the rollover. Here 29 of the 172 trades (17%) enter at that moment.
We then ran the same test again with the rollover minute treated as an ordinary minute, which is what a backtest on hourly bars does when it ignores the hours in which the broker accepts orders: a fill at the first quoted price of the hour, the usual spread, and stops and targets triggered by quotes from the refused minute.
- Rollover minute treated as an ordinary minute
- The lab: tradable minutes only
The result: -7.0% with tradable minutes only, +1.9% with the rollover treated as an ordinary minute. Most of the gap comes from the 29 trades entered just after midnight: they add up to -5.3 R in the lab, against +2.8 R in the naive version. A losing strategy becomes a winning one without a single setting changing.
Why a standard backtest gets this wrong
Two errors stack up. The first is cost: an order sent just after midnight pays a spread several times wider than usual, while a backtest using an average spread charges it the daytime rate. The second is price: during the refused minute, quotes often spike, and a backtest that takes them at face value triggers stops or targets at prices nobody could have been filled at.
The effect depends on when a strategy places its orders. A rule that often enters just after midnight, like this one on four-hour bars, is highly exposed; a rule that almost never trades then is much less so. The lab only fills orders in the minutes when the broker actually accepts them, at the spread of that moment: the lab's Method section explains how those minutes are isolated, with the example of one specific night. To hold your own strategies to the same standard, open this one in the lab.
Design period against out-of-sample
Design period: Aug 1, 2022 to Jun 27, 2025
- Result
- -9.1%
- Trades
- 124
- Maximum drawdown
- 15.4%
- In R
- -9.0 R
Out-of-sample: Jun 27, 2025 to Sep 25, 2026
- Result
- +2.4%
- Trades
- 48
- Maximum drawdown
- 5.6%
- In R
- +2.6 R
Tune the strategy while looking at the design period, then judge it on the out-of-sample period, which played no part in the tuning. A wide gap between the two often means the settings were fitted to the past.
Year by year
| Year | Trades | Result (R) |
|---|---|---|
| 2022 | 19 | -3.1 R |
| 2023 | 44 | +1.7 R |
| 2024 | 45 | -9.5 R |
| 2025 | 35 | +6.8 R |
| 2026 | 29 | -2.3 R |
In R, the multiple of the risk taken on each trade: a yearly total cannot be read as a % of the account, since gains and losses compound from one year to the next.