Why Local Agents Matter for MT5 Backtesting
If you've ever run a genetic optimization in MetaTrader 5 and watched the progress bar crawl through 10,000 passes on a single core, you know the pain. MT5's Strategy Tester can use multiple CPU cores simultaneously, but only if you configure local agents correctly. The default installation gives you one agent — meaning you're using one core while the other seven sit idle. That's the difference between a 20-minute optimization and a 3-hour one.
This guide walks you through setting up local agents on your own machine, configuring network agents across multiple PCs, and tuning memory limits so the tester doesn't crash mid-run. You'll end up with a system that uses every available core, turning those overnight optimizations into lunch-break tasks.
Prerequisites
Before diving into agent configuration, make sure you have these basics covered:
- MT5 build 2000 or newer. Older builds (pre-1800) had a different agent architecture. You can check your build under Help > About in the terminal. If it's older than build 2000, update via Help > Check for Updates.
- A funded or demo trading account with at least one active symbol. The Strategy Tester needs a working symbol with history data loaded.
- At least 8 GB of RAM for local agents (16 GB+ recommended for 6+ agents). Each agent spawns a separate MetaTrader 5 process that loads the entire tester environment, so memory adds up fast.
- A multi-core CPU — Intel i5 or AMD Ryzen 5 or better. The whole point is parallel processing, so a dual-core machine won't benefit much.
- Windows 10/11 Pro or Enterprise if you plan to use network agents. Windows Home edition cannot join a workgroup cleanly, which complicates network agent discovery.
- Admin rights on your machine to install the MetaTrader 5 Tester Agent service.
Step-by-Step: Setting Up Local Agents in MT5
Step 1: Enable the Strategy Tester Agent Service
MT5's agents run as a Windows service called MetaTester 5. If the service isn't running, no agents will appear in the tester dialog.
- Open the Windows Services console: press Win + R, type
services.msc, and hit Enter. - Scroll down to MetaTester 5. If you don't see it, you need to reinstall MT5 with full components (the default installer includes it).
- Right-click MetaTester 5 and select Start if it's stopped. Set the startup type to Automatic (right-click > Properties > Startup type > Automatic) so it starts when you boot your PC.
- Close the Services console.
Step 2: Open the Strategy Tester and Configure Agents
- In MT5, open the Strategy Tester (Ctrl + R or View > Strategy Tester).
- Click the Agents tab at the bottom of the tester panel. This tab shows all available agents — local and network.
- Click the Settings button (gear icon) in the Agents tab. A dialog titled Testing Agents opens.
- Under Local Agents, you'll see a list of agents. By default, there's one agent named Local #1 with status "Active".
- Click Add to create additional local agents. Each agent corresponds to one CPU core that the tester will use for parallel passes.
Step 3: Set the Number of Agents and Memory Limits
| Setting | Recommended Value | Notes |
|---|---|---|
| Number of agents | Number of physical cores - 1 | Leave one core for the OS and MT5 UI. On a 6-core CPU, use 5 agents. For hyper-threaded CPUs, count physical cores only. |
| Memory limit per agent | 512 MB (or 1024 MB for complex EAs) | Each agent loads a full copy of MT5. If your EA uses large arrays or tick data, increase this. Watch total RAM usage — 6 agents × 1024 MB = 6 GB plus the main MT5 process. |
| Enable all agents | Checked | If you uncheck an agent, it won't be used. Leave all checked unless troubleshooting. |
To set these values:
- In the Testing Agents dialog, select a local agent and click Edit.
- In the Memory limit (MB) field, enter 512 (or 1024 if you have 16+ GB RAM).
- Repeat for each agent. You can select all agents and click Edit to apply the same memory limit to all at once.
- Click OK to save.
Step 4: Verify Agents Are Running
Back in the Agents tab of the Strategy Tester, you should see all your local agents listed with status "Active". If any show "Offline", the MetaTester 5 service may not be running, or the agent process crashed. Restart the service from Windows Services and check again.
Step 5: Run a Backtest with All Agents
- Select your EA or indicator in the Strategy Tester.
- Set the symbol, timeframe, and date range as usual.
- Under Testing mode, choose Every tick for the most accurate results (though it's slower — agents help offset this).
- Under Optimization, select Slow complete algorithm or Genetic algorithm based on your needs. Genetic optimization benefits most from parallel agents.
- Click Start. The tester will distribute passes across all active agents.
Watch the Agents tab during the run. You should see each agent processing a separate pass in parallel. If only one agent shows activity, something is misconfigured — check the troubleshooting section below.
Setting Up Network Agents (Multi-PC Optimization)
If you have multiple computers on your local network, you can pool their cores for even faster optimization. This is useful for teams or for traders with a dedicated backtesting rig. Network agents require a bit more setup but the payoff is significant.
Step 1: Install MT5 Tester Agent on Each Machine
On each machine you want to add as a network agent:
- Install MetaTrader 5 (same build as the main machine).
- During installation, ensure the MetaTester 5 component is checked. By default it's included.
- After installation, open Services console and start the MetaTester 5 service. Set it to Automatic.
Step 2: Configure Network Discovery
All machines must be on the same local subnet and able to see each other. For Windows:
- On each machine, go to Control Panel > Network and Sharing Center > Advanced sharing settings.
- Turn on Network discovery and File and printer sharing for your network profile (Private or Domain).
- Make sure the Windows Firewall allows the MetaTester 5 service through. The installer usually adds a rule, but you can verify by going to Windows Defender Firewall > Allow an app or feature through Windows Firewall and confirming MetaTrader 5 Tester Agent is checked for Private networks.
Step 3: Add Network Agents in MT5
- On your main MT5 machine, open the Strategy Tester and go to the Agents tab.
- Click Settings (gear icon).
- In the Network Agents section, click Add.
- Enter the IP address or computer name of the remote machine. For example:
192.168.1.50orDESKTOP-BACKTEST. - Set the Memory limit for that agent (same considerations as local agents).
- Click OK. MT5 will attempt to connect to the remote agent. If successful, it appears in the agents list with status "Active".
Step 4: Test the Connection
Run a short backtest (5-10 minutes of data) with optimization enabled. Check the Agents tab to confirm both local and network agents are processing passes. If a network agent shows "Offline", verify the remote service is running and the firewall rules are correct.
Tips and Best Practices from Experience
- Don't max out your cores. I usually leave one physical core free for the OS and the MT5 interface. If you use all cores, the UI becomes unresponsive and you can't even cancel a running optimization without forcing a crash.
- Match memory limits to your EA. A simple moving average crossover EA with 3 inputs uses maybe 200 MB per agent. A neural-network EA with 50 inputs and large buffers can use 1.5 GB. If an agent runs out of memory, it silently crashes and the tester reassigns its work to another agent — slowing things down. Start with 512 MB and increase if you see agent failures.
- Use SSD storage for the tester cache. MT5 writes tick data and cache files to
%APPDATA%\MetaQuotes\Terminal\...\Tester. If that's on an HDD, I/O becomes the bottleneck long before CPU. Move it to an SSD if possible. - For network agents, use wired Ethernet. Wi-Fi adds latency and occasional packet loss that can cause agents to drop offline mid-optimization. A cheap gigabit switch and Cat6 cables are worth the investment.
- Monitor agent health. During a long optimization, glance at the Agents tab every few minutes. If an agent shows "Error" or "Offline", the tester redistributes its work, but the overall run time increases. Log the errors and investigate after the run.
Common Mistakes and Troubleshooting
"No agents available" or "Agent is offline"
Cause: The MetaTester 5 service isn't running, or the agent process crashed due to memory limits.
Fix: Restart the service from Services console. Check the Windows Event Viewer (Applications and Services Logs > MetaQuotes) for crash details. Increase the memory limit for that agent if crashes correlate with high memory usage.
Only one agent shows activity despite adding 6
Cause: The tester is running in single-pass mode (non-optimization), or the optimization algorithm doesn't parallelize well. Genetic optimization uses all agents; simple forward-only backtests use only one.
Fix: Enable optimization in the tester settings. If you're already optimizing, the problem might be that your EA has only one input parameter with few values — the tester can't split work across agents if there's only a handful of passes. Add more parameter combinations or use the genetic algorithm which generates many passes.
Network agent shows "Connection refused"
Cause: Firewall blocking the connection, or the remote MetaTester 5 service isn't running.
Fix: On the remote machine, open services.msc and verify MetaTester 5 is running. Temporarily disable Windows Firewall on the remote machine to test (re-enable after). If that works, add a specific inbound rule for port 8082 (the default port for MT5 tester agents) in the firewall.
Backtest results differ between single-core and multi-agent runs
Cause: This is normal to some degree. When running multiple agents, the tester uses a different random seed for genetic optimization passes, leading to slightly different results. For complete algorithm optimization, results should be identical. If you see large discrepancies, check that your EA doesn't use global variables or file operations that conflict across agents — each agent runs in a separate process, so shared resources cause race conditions.
Summary
Setting up MT5 local agents is the single most effective way to speed up backtesting without buying new hardware. You configure agents through the Strategy Tester's Agents tab, matching the count to your physical cores minus one, and adjusting memory limits based on your EA's footprint. Network agents let you pool multiple computers for even faster optimization, but require proper network configuration and wired connections for reliability.
Once agents are running, you'll see optimization times drop dramatically — I've seen 8-hour genetic optimizations finish in under 90 minutes on a 6-core machine with 5 agents. The next step is to fine-tune your EA's input ranges to maximize the benefit of parallel processing, but that's a topic for another guide.
Frequently Asked Questions
How many local agents should I create for my CPU?
Create one agent per physical core, minus one for the OS. On a 4-core CPU, use 3 agents. On an 8-core CPU, use 7. Hyper-threading doesn't help here — MT5 uses physical cores only. You can check your core count in Task Manager under the Performance tab.
Can I use network agents with a demo account on the remote machine?
No. The remote machine only needs the MetaTester 5 service running — it doesn't need a trading account at






