Task Packaging and Distribution via MQL5 Cloud Network
The Strategy Tester in MetaTrader 5 distributes optimization tasks to both local and remote agents through the MQL5 Cloud Network, which aggregates thousands of agents globally. Local agents are created automatically based on the number of logical cores available on the user's computer, and each agent operates independently to process optimization passes in parallel. The platform acts as a manager, assigning tasks to agents and collecting results once completed. An unlimited number of remote agents can be connected, expanding computational capacity beyond the local machine. The MQL5 Cloud Network makes this vast computational power accessible to any platform user without requiring additional hardware.
When a test is initiated, the platform prepares multiple parameter blocks including simulation mode, testing interval, instruments, optimization criterion, and the Expert Advisor to be tested. Each block is assigned a unique MD5 hash, which serves as a digital fingerprint to identify the parameter set. These hashes are sent to the agents rather than the full data, significantly reducing network traffic. If an agent does not have the corresponding parameter block or the hash differs from its stored version, it requests the full block from the platform. This efficient data exchange mechanism ensures that only necessary information is transmitted during the optimization process.
Sources: MetaTrader 5 documentation: testing MetaTrader 5 documentation: features
Data Exchange and Communication via MD5 Hashes
The communication protocol between the platform and testing agents relies heavily on MD5 hashes to minimize data transfer. For each parameter block—such as input parameters, symbol lists, Expert Advisor specifications, and additional files like libraries or indicators—a unique MD5 hash is generated and sent to the agent. The agent compares these hashes with its locally stored sets. If a match is found, no further data is requested; if not, the agent requests the full parameter block. This approach drastically reduces bandwidth usage, especially during large-scale optimizations involving hundreds of parameter combinations.
After testing completes, the agent returns the results to the platform, which are displayed in the Test Results and Optimization Results tabs. These include metrics such as profit, number of deals, Sharpe ratio, and the output of the OnTester() function. During optimization, tasks are distributed in small packages, each containing several parameter sets, to further reduce data exchange. Importantly, agents never write EX5 files received from the platform to disk for security reasons, ensuring that remote computers cannot utilize the received data for unauthorized purposes.
Sources: MetaTrader 5 documentation: features
Documented Limitations on Remote Agents
Remote agents operate under several documented restrictions designed to maintain security and system integrity. Most notably, DLL calls are absolutely prohibited on remote agents, as stated in the platform documentation. This means Expert Advisors that rely on external dynamic-link libraries cannot be tested or optimized using remote agents. On local agents, DLL calls are permitted only if the 'Allow import DLL' permission is explicitly enabled in the platform settings, and users must be aware of the risks associated with third-party code that requires such permissions.
Additionally, remote agents produce significantly reduced logging compared to local agents. Messages from the Print() function, as well as notifications about position openings and closings, are not recorded in remote agent logs. This limitation exists to prevent hard drives from being overwhelmed by excessive logging from poorly designed Expert Advisors. Only essential information is transmitted back to the platform, ensuring efficient operation even under heavy optimization loads. These restrictions ensure that remote agents remain secure, stable, and resource-efficient while still providing powerful computational support for strategy optimization.
Sources: MetaTrader 5 documentation: features
History Synchronization and Data Handling
When testing multi-currency strategies, the Strategy Tester automatically downloads historical data for all symbols used in the Expert Advisor. The testing agent requests this history from the platform upon the first call of a 'foreign' symbol—defined as any symbol different from the main testing instrument. At this point, testing pauses temporarily while the required data is synchronized between the agent and the platform. If the platform already has the data available, it is transferred immediately; otherwise, it is downloaded from the trade server first.
The history is stored in a compressed format to reduce network traffic, and ticks are never sent over the network—instead, they are generated locally on the testing agents. For timeframes of D1 and below, the minimum downloaded history is one year, while weekly timeframes require approximately two years (100 bars), and monthly timeframes require about eight years (96 months). If insufficient data is available, the start date of testing is automatically shifted forward to ensure at least 100 bars are present for accurate indicator calculations. This automatic adjustment is accompanied by a message in the Strategy Tester journal.
Sources: MetaTrader 5 documentation: testing MetaTrader 5 documentation: features
Visual Testing and Local Agent Requirements
Visual testing, which allows real-time visualization of Expert Advisor operations on historical data, is only available on local agents. If a remote agent is selected for testing, users must explicitly switch to a local agent using the 'Select' command in the agent's context menu. This restriction exists because visual testing requires direct access to chart rendering and local display capabilities, which remote agents cannot provide.
When visual testing is enabled, a new window opens that simulates a separate trading platform instance, complete with charts, Market Watch, and Toolbox windows. All trades performed during the test are displayed as icons on the chart, with dotted lines connecting market entries and exits. The testing process can be controlled via the toolbar, allowing users to pause, speed up, or slow down the simulation. Hot keys are available for quick navigation, and users can jump to specific dates within the test period. The visualizer also supports indicator display and template application, provided the template name matches the Expert Advisor and is stored in the platform's templates folder.
Sources: MetaTrader 5 documentation: testing MetaTrader 5 documentation: features
AI-assisted educational article. Automated checks reviewed source support and quality; they do not guarantee accuracy. This is not investment advice. Leveraged and automated trading involves substantial risk of loss.
Sources & further reading
MetaTrader 5 documentation: testingMetaTrader 5 documentation: featuresEducational content only. This article is not investment advice. Automated and leveraged trading involves substantial risk of loss.