Quant Invest System

How swap costs break H4 and D1 backtests

An intraday strategy rarely holds a position past rollover, so swap barely touches it. A strategy on four-hour or daily bars holds for days, pays or earns swap every night, and its average trade is often not much larger than that bill. In a backtest over several years, the swap used is also probably not the one that applied at the time.

What swap is

A position open at the broker’s daily rollover, usually midnight server time, is charged or credited swap: the interest difference between the two currencies of the pair (or the financing rate of a CFD), plus the broker’s markup. Long and short usually differ, and with the markup both can be negative.

Once a week the swap is charged three times, to cover the weekend. For most currency pairs that happens on Wednesday; for many index, metal and other CFDs it is another day. The symbol specification in MetaTrader 5 shows it as 3-day swap, next to Swap long, Swap short and the swap type (points, money, percent and others).

Why a long backtest gets it wrong

The specification holds one swap long and one swap short: today’s. Interest rates were not the same over the years a backtest covers. In 2021 the Federal Reserve’s rate was near zero and the ECB’s deposit rate was −0.5%; by late 2023 they were 5.5% and 4.0%. The Bank of Japan kept its rate at −0.1% until March 2024. Holding a USD/JPY long overnight went from a near-zero difference to more than five percentage points a year in its favour within two years.

MetaTrader 5 documentation does not describe historical swap rates for testing, and the specification has no place for them. Check what your test used: take one trade held over several rollovers, count the nights including the triple day, multiply by the current swap from the specification, and compare with the Swap column of its deal in the report. If they match, the test applied today’s swap to every year.

The error is not random. A strategy that mostly buys high-yielding currencies, such as a long USD/JPY trend follower, is credited today’s carry for years when there was none. One that mostly sells them is charged today’s cost for years when it was small.

How much of the average trade it takes

Measure the swap in the same unit as your risk. If the stop is S pips and the swap per night is w pips, a trade held N nights pays

swap in R ≈ N · w / S

where N counts the triple day as three nights. Compare that with the average trade in R, which is the edge.

Swap as a share of a 0.10R average trade, at 0.6 pips per night
ProfileStopNights held, averageSwap per tradeShare of the edge
H1, mostly intraday15 pips0.30.012R12%
H4 swing40 pips20.030R30%
D1 trend120 pips90.045R45%
D1 trend, slow exit120 pips200.100R100%

These are calculations with an assumed swap of 0.6 pips a night (about 6 USD a night for one lot of EUR/USD), not the rate of any broker. A wider stop does not make swap disappear: trend followers with wide stops also hold longest. And because swap comes off the average trade but hardly changes how much trades vary, it raises the number of trades a result needs sharply; at half the edge, about four times as many. You can see that with the PSR calculator.

What to check in your report

  1. Add up the Swap column of the deals and compare it with the total net profit. If swap is a large share, the result depends on interest rates as much as on the rule.
  2. Split by direction. Long and short trades pay different swap. If one side carries the result, check its swap separately.
  3. Re-run with a different swap. A custom symbol (a copy of the broker symbol with its own specification) lets you set swap long and short yourself. Test with zero and with a deliberately worse value; a result that only survives with today’s swap is a result about today’s rates.
  4. Check the triple day. A strategy that tends to hold over Wednesday, or the CFD’s triple day, pays more than the nightly rate suggests.
  5. Swap-free accounts usually replace swap with other fees after a number of days. A test with swap set to zero does not model them.

How we handle it

A Report Audit takes swap as it appears in your report and lists it with commission and spread, labelled as observed. In our own backtests swap is an estimate per asset class, listed in the report, not the rate of your broker. Neither reconstructs historical swap rates. See the methodology, how to read an MT5 report, or check your file for free.

Sources

  • MetaTrader 5 Help: Symbol specification; Custom symbols.
  • Federal Reserve: federal funds target range, 2020–2024. European Central Bank: key interest rates, deposit facility. Bank of Japan: policy rate decision of 19 March 2024.