Building a Multi-Symbol, Multi-Timeframe Python Trading Simulator
Summary
The article describes extending a Python-based MetaTrader 5 strategy tester to handle data for multiple instruments and timeframes. It introduces a history manager that fetches bars or ticks for a set of symbols, stores historical data locally, and supports several simulation modes, including real ticks, generated ticks, new bars, and one-minute OHLC data. The workflow uses concurrent fetching and separates history management from the rest of the tester.
The article also addresses aligning each instrument’s bars to a shared testing timeline, organizing data for multithreaded instrument handling, and reducing performance and memory costs. It compares the custom tester’s behavior with MetaTrader 5’s native multi-symbol access and concludes that direct terminal data access can be faster and more memory-efficient where supported. The examples show a multi-currency robot and tester output, but do not provide a controlled benchmark or general performance measurements. Practical results depend on platform support, data availability, configuration, and implementation details.
Key ideas
- A history manager can fetch and persist bars or ticks for multiple instruments before a simulation begins.
- The tester supports several data modelling modes, including real ticks and synthetic ticks generated from bars.
- Concurrent fetching and multithreaded instrument processing are used to handle larger multi-symbol workloads.
- Data must be aligned across instruments and timeframes for coherent multi-currency testing.
- The article reports that direct terminal history access can improve speed and memory use on supported platforms, without presenting a controlled benchmark.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.