Skip to content
All library documents

Building a Multi-Pair Forex Backtest with Moving Average Crossovers

Article QuantStart

Summary

This article presents a simplified interface for configuring a forex backtest and extending it to multiple currency pairs. A Backtest object is assembled from price data, strategy, portfolio, and simulated execution components, with strategy settings passed as parameters. The example applies a moving average crossover to GBP/USD and EUR/USD using tick data. It maintains separate state for each pair, calculates rolling short and long averages, enters long when the short average rises above the long average, and exits when it falls below.

The author reports running the example on two months of data and describes the resulting performance as poor, with the strategy largely underwater. The run also takes substantial time on the author’s system, highlighting the cost of tick-level simulation and performance calculations. This is an implementation example, not evidence that the method is profitable. The crossover is long-only, uses market orders, and its rolling average initialization and parameter choices may affect results. The article identifies faster computation and support for limit orders as future development needs.

Key ideas

  • The Backtest interface bundles data, strategy, portfolio, and simulated execution components.
  • A separate state record allows the moving average crossover to operate independently on multiple currency pairs.
  • The example opens long positions when the short average exceeds the long average and closes them on a reverse crossover.
  • The reported tick-data backtest performs poorly, so the simple crossover is not presented as a profitable strategy.
  • Market-only execution and slow simulation limit the example’s realism and scalability.

Tags

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