Forex backtest costs: spread, commission and swap
A forex backtest needs three costs: the spread on every round trip, any commission per lot, and swap for each rollover a position is held through. Leave one out and the result looks better than it is.
By Soren Huang · Published · updated · Editorial policy
Contents
A forex backtest should charge three costs: the bid-ask spread once per round trip, the broker's commission per lot if the account has one, and swap for every daily rollover the position is held through. The spread matters most for short trades; swap matters most for trades held for days or weeks.
Which costs does a forex trade pay?
A forex trade pays the spread, sometimes a commission, and swap when it is held overnight. The spread is the gap between the bid price you sell at and the ask price you buy at. A commission is a fixed charge per lot that some account types add in exchange for a narrower spread. Swap is the overnight interest adjustment explained below.
| Cost | When it is charged | What sets its size | Matters most for |
|---|---|---|---|
| Spread | Once per round trip | Pair, time of day, market conditions | Short-term and intraday strategies |
| Commission | Per lot, often per side | Account type | Strategies that trade often |
| Swap | Each daily rollover a position is held through | Interest rates of the two currencies and the broker's markup | Positions held for days or weeks |
| Slippage | Market and stop orders | Liquidity and news | Breakout and news-driven entries |
The same idea applies to futures, where commission, exchange fees and slippage play this role. The guide to trading costs in backtests: commission, slippage and the average trade shows how to compare the total cost with the average trade.
How do you put the spread into a backtest?
Charge the spread in pips once per round trip, using a value that matches the hours your strategy trades. Many backtests run on bid prices only, so a long trade enters at the bid when in practice it would pay the ask. The simplest correction is to subtract the typical spread from every trade's result.
Spreads are not constant. They are usually tightest when the major sessions overlap and wider around the daily rollover, the weekly open and major news releases. A strategy that trades at those times needs a wider spread in the test than the quoted average.
How is swap calculated, and why is Wednesday different?
Swap is the position size times the swap rate for that pair and direction, charged or paid at each daily rollover the position is held through. Swap is the interest adjustment for holding a currency position past the rollover, which most brokers set at 17:00 New York time. It reflects the interest-rate difference between the two currencies plus the broker's markup, so one direction often pays while the other earns less or also pays.
Spot forex trades settle two business days later, so a position held through Wednesday's rollover is charged for the weekend as well. Most brokers therefore apply three nights of swap on Wednesday for most pairs; the broker's swap calendar shows the exceptions. A backtest that charges one night for every calendar day, or skips the Wednesday triple, misstates the cost of trades held over the middle of the week.
Hypothetical example
A strategy holds one standard lot long from Monday to Friday, through four daily rollovers. The broker's long swap is −0.8 pips per night. Wednesday counts three times, so the position is charged for six nights: 6 × 0.8 = 4.8 pips, about $48 if one pip is worth $10.
Which pip value turns a cost into money?
Convert every cost in pips into money with the pip value of the pair, the lot size and the account currency. For a standard lot of 100,000 units of a pair quoted in US dollars, such as EUR/USD, one pip is worth $10 in a US-dollar account; a mini lot is worth $1 per pip and a micro lot 10 cents. For a pair quoted in another currency, the pip value changes with the exchange rate, so the same cost in pips is worth a different amount from one day to the next.
How do you tell whether costs erase a forex strategy's edge?
Compare the total cost per trade with the average trade before costs. When spread, commission and swap together take most of the average trade, small changes in any of them decide the result. Then run the test again with the spread 1.5 times as wide; a strategy whose result collapses depends on fills you may not get.
- Set the spread for each pair for the hours the strategy trades.
- Add the commission per lot and per side if the account charges one.
- Charge swap at each rollover, by direction, with three nights on Wednesday.
- Read the average trade after costs and the number of trades; the free win rate and expectancy calculator turns wins and losses after costs into the average result per trade.
- Test the rules on later data they never saw, as in walk-forward analysis.
What this means if you use MultiAlphas (Valynox): the same discipline applies to every strategy it generates. Costs are part of each test, and the average trade after costs is the number to read most closely in the Performance Report.
Frequently asked questions
Is the spread paid on entry and again on exit?
You cross the spread once per round trip. You buy at the ask and sell at the bid, so the gap between them is paid one time for a complete trade, not once on each side.
Why is swap different for long and short positions?
Swap follows the interest-rate difference between the two currencies. Holding the higher-yielding currency tends to earn, holding the lower-yielding one tends to pay, and the broker's markup is taken from both directions.
Does a strategy that closes before the rollover pay swap?
No. Swap is charged only on positions still open at the daily rollover. An intraday strategy that is flat at that time pays the spread and any commission, but no swap.
Should a forex backtest use bid or ask prices?
Either works if the spread is charged. Data based on bid prices needs the spread added to every long entry and short exit, or subtracted once from every trade's result.