Skip to content
All library documents

Multi-Pair Forex Backtesting and Moving Average Crossovers

Article QuantStart

Summary

This diary entry describes updates to a forex backtester that enable trading multiple currency pairs and accounts denominated in currencies other than the traded pair. It explains how positions convert profit and loss from the quote currency into the account currency, and how position objects now handle adding units, removing units, and closing trades. The implementation excludes pairs involving Japanese yen because its tick-size handling has not been adapted.

The strategy example is a long-only moving average crossover: enter when a short simple moving average rises above a longer one, and exit when it falls below. Rolling calculations reduce repeated work. The author also describes a single-threaded, deterministic backtest and a basic equity curve export. The curve records balance only when signals occur, so it omits unrealised profit and loss and can misrepresent performance between trades. Multi-day streaming and time-binned returns for performance metrics remain planned, so the described system is an evolving research tool rather than a complete evaluation framework.

Key ideas

  • A multi-pair forex backtester must convert trade profit and loss from the quote currency into the account currency.
  • Position-level methods can manage unit changes and closing calculations while leaving the portfolio to update its balance.
  • A long-only moving average crossover enters when the short average exceeds the long average and exits after the reverse crossover.
  • A balance-only equity curve misses unrealised profit and loss and can give a misleading view of a strategy between signals.
  • Reliable longer-term analysis also requires multi-day data streaming and return sampling suited to the trading frequency.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.