Automatic Creation and Independent Operation of Local Agents
The MetaTrader 5 platform automatically creates and enables local testing agents when the Strategy Tester is launched. The number of available local agents is determined by the number of logical cores detected on the host computer. Each agent operates as an independent service, running its own instance of global variables that are completely separate from the global variables of the main trading platform. This independence ensures that the state of one agent does not interfere with the state of another or with the platform itself. The platform acts as the central manager, responsible for distributing testing tasks to both local and remote agents based on availability and configuration.
Each individual test run is assigned to exactly one agent, ensuring that the test is executed in isolation with its own copy of global variables and a dedicated history folder. Once the task is complete, the agent transmits the results back to the platform, which then aggregates them into the 'Test Results' and 'Optimization Results' tabs. This design prevents the overhead of repeatedly initializing and loading the agent into CPU memory for subsequent tests, as the agent enters a standby state after finishing a task.
Sources: MetaTrader 5 documentation: features MetaTrader 5 documentation: testing
Standby Behavior and Task Interruption Protocols
After finishing a task, a local agent does not immediately shut down. Instead, it enters a standby state, remaining active and waiting for additional tasks for a period of five minutes. This design prevents the overhead of repeatedly initializing and loading the agent into CPU memory for subsequent tests. If no new task is received within that five-minute window, the agent terminates itself and is unloaded from memory. In the event of an interruption—such as the user clicking the 'Cancel' button or closing the trading platform—all local agents stop immediately and are unloaded.
The platform maintains a cache of previous results. Before assigning a new task to an agent, the platform checks this cache to see if the specific parameter combination has already been tested, avoiding redundant computations and saving processing power. During optimization, the platform distributes tasks in small packages, each containing several parameter sets, to minimize the volume of data exchanged. All communication between the platform and the testing agents is encrypted to protect sensitive data, including trading parameters, symbol specifications, and test results.
Sources: MetaTrader 5 documentation: features MetaTrader 5 documentation: testing
History Storage and Data Isolation on Agents
Each testing agent maintains its own storage structure for historical data, keeping it isolated from the platform and other agents. The history for a specific symbol is stored in a dedicated folder named after that symbol. Furthermore, the agent separates historical data based on its source, such as the specific server it was downloaded from. The directory structure follows a precise pattern: 'tester_catalog Agent-IPaddress-Port bases name_source history symbol_name'. For example, data for EURUSD downloaded from the MetaQuotes-Demo server would reside in 'tester_catalog Agent-127.0.0.1-3000 bases MetaQuotes-Demo EURUSD'. This organization ensures that data from different sources or symbols does not conflict.
When a test begins, the platform sends the necessary historical data to the agent in a compressed format to minimize network traffic. Crucially, raw tick data is never transmitted over the network; instead, the agent generates the tick sequences locally based on the selected tick generation mode. To reduce data transfer further, the platform and agents use MD5 hashes to verify if the agent already possesses the required parameter blocks and symbol specifications. If the hash matches, the data is not resent, saving bandwidth and processing time.
Sources: MetaTrader 5 documentation: features MetaTrader 5 documentation: testing
Visual Mode Restriction to Local Agents
The visual testing mode in MetaTrader 5, which allows users to observe an Expert Advisor's operations on a chart in real-time, has a strict technical limitation: it can only be executed on local testing agents. This restriction exists because visual mode requires direct access to the local graphical interface to render charts, the Market Watch, and the Toolbox. If a user attempts to run a visual test and a remote agent is currently selected, they must manually switch to a local agent using the 'Select' command in the agent's context menu before starting the test.
When visual testing is active, the platform opens a new window that simulates a separate trading environment. This window contains the chart, Market Watch, and Toolbox, allowing the user to monitor trades, view indicator values in the Data Window, and inspect order histories. Because the visualizer is a local process, the logs generated by the testing agents during a visual run are not automatically sent back to the main Strategy Tester window. To view these logs, the user must access them via the 'Local Journals of local agents' command in the platform's context menu.
Sources: MetaTrader 5 documentation: testing
Security Protocols and File Handling
To prevent security vulnerabilities, MetaTrader 5 implements strict rules regarding how testing agents handle incoming files. Agents never write received Expert Advisor executable files (EX5), indicators, or libraries to the hard disk. This ensures that a compromised or unauthorized computer running an agent cannot execute or repurpose the received trading algorithms. The only exception to this rule is for Dynamic Link Libraries (DLLs), which are recorded in a secure sandbox environment. However, the use of DLLs is completely prohibited on remote agents, and on local agents, it is only permitted if the 'Allow import DLL' option is explicitly enabled in the platform settings.
During optimization, the platform distributes tasks in small packages, each containing several parameter sets, to minimize the volume of data exchanged. Furthermore, the platform maintains a cache of previous results. Before assigning a new task to an agent, the platform checks this cache to see if the specific parameter combination has already been tested, avoiding redundant computations and saving processing power. All communication between the platform and the testing agents is encrypted to protect sensitive data, including trading parameters, symbol specifications, and test results.
Sources: MetaTrader 5 documentation: features MetaTrader 5 documentation: testing
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: featuresMetaTrader 5 documentation: testingEducational content only. This article is not investment advice. Automated and leveraged trading involves substantial risk of loss.