Connect to MetaTrader 5
This guide walks you through connecting your Agentic Traders agent to MetaTrader 5 (MT5). Once connected, your AI agent's trading decisions will be automatically executed on your MT5 account—whether demo or live.
What You'll Need
Before you begin, make sure you have:
- An Agentic Traders account (PRO or ELITE tier required for live trading)
- MetaTrader 5 installed on your computer
- A broker account that supports MT5 (most forex brokers do)
- About 10 minutes to complete the setup
New to MT5? We strongly recommend starting with a demo account first. This lets you test the integration without risking real money. Most brokers offer free demo accounts with virtual funds.
How It Works
Here's what happens when you connect your agent to MT5:
- Your agent analyzes the market using the indicators and strategy you configured
- When it decides to trade, it sends a signal to our servers
- Our EA (Expert Advisor) running in your MT5 terminal receives the signal
- The EA executes the trade on your broker account
- Position updates sync back so your agent knows what's open
The entire process happens in seconds, allowing your agent to trade 24/7 without manual intervention.
Step 1: Download and Install MetaTrader 5
If you don't already have MT5 installed, you'll need to download it first.
Option A: Download from your broker
Most brokers provide their own branded version of MT5. Check your broker's website for their download link. This is often the easiest option since it comes pre-configured with your broker's servers.
Option B: Download from MetaQuotes
You can also download the standard MT5 from the official website:
Download MetaTrader 5 from MetaQuotesCreating a Demo Account
If you're new to MT5 or want to test the integration:
- Open MT5 after installation
- Go to File → Open an Account
- Search for your broker or select "MetaQuotes Software Corp" for a test account
- Choose Demo account and follow the prompts
- Note down your login credentials—you'll need them later
Step 2: Download the AgenticTraders EA
The Expert Advisor (EA) is the bridge between your Agentic Traders agent and MT5. It's a small program that runs inside MT5, constantly listening for signals from your agent.
Coming Soon: The EA download will be available directly from your dashboard. You'll be able to download it from the Connect Broker page once it's ready.
The EA file you'll receive is called AgenticTradersEA.ex5. This is a compiled Expert Advisor that works with any MT5 broker.
Step 3: Install the EA in MetaTrader 5
Once you have the EA file, you need to place it in the correct folder:
- Open MT5 and log into your account
- Go to File → Open Data Folder (this opens Windows Explorer)
- Navigate to MQL5 → Experts
- Copy the
AgenticTradersEA.ex5file into this folder - Go back to MT5 and find the Navigator panel (usually on the left side)
- Right-click on Expert Advisors and select Refresh
You should now see "AgenticTradersEA" in your list of Expert Advisors.
Can't find the Navigator panel? Press Ctrl+N or go to View → Navigator to show it.
Step 4: Generate an API Key
The EA needs an API key to securely communicate with your Agentic Traders account. This key proves to our servers that the EA is authorized to receive signals for your agents.
- Log into your Agentic Traders dashboard
- Go to Settings (gear icon in the sidebar)
- Click on the API Keys tab
- Click Generate New Key
- Give it a name like "MT5 Connection" so you remember what it's for
- Important: Copy the key immediately and save it somewhere secure
Save your API key now! For security reasons, we only show you the full key once. If you lose it, you'll need to generate a new one.
Finding Your Agent ID
You'll also need your Agent ID to configure the EA:
- Go to your Agents page
- Click on the agent you want to connect
- Open the agent's Settings tab
- Copy the Agent ID (it looks like:
abc12345-def6-7890-ghij-klmnopqrstuv)
Step 5: Configure MT5 Settings
Before the EA can communicate with our servers, you need to enable a few settings in MT5.
Enable WebRequest (Required)
MT5 blocks external web connections by default. You need to whitelist our server:
- In MT5, go to Tools → Options
- Click the Expert Advisors tab
- Check the box: "Allow WebRequest for listed URL"
- Click Add and enter:
https://app.agentictraders.io - Click OK to save
Enable Algorithmic Trading (Required)
The EA needs permission to place trades:
- Look at the MT5 toolbar at the top
- Find the Algo Trading button (it may say "AutoTrading" in some versions)
- Click it so it turns green
- Alternatively, press Ctrl+E to toggle it
Why is this needed? These settings are MT5's safety features to prevent unauthorized programs from placing trades or connecting to unknown servers. By enabling them, you're telling MT5 that you trust the AgenticTraders EA.
Step 6: Attach the EA to a Chart
Now it's time to activate the EA:
- In the Navigator panel, find Expert Advisors → AgenticTradersEA
- Drag and drop it onto any chart (the chart's symbol doesn't matter—the EA handles all symbols)
- A settings dialog will appear with several inputs
Configure the EA Settings
Fill in the following fields:
| Setting | Value |
|---------|-------|
| API Key | Paste the API key you generated in Step 4 |
| Agent ID | Paste your Agent ID from the agent's settings |
| Server URL | https://app.agentictraders.io (default) |
| Enable Trading | true for live execution, false for monitoring only |
- Click the Common tab
- Make sure "Allow Algo Trading" is checked
- Click OK
Step 7: Verify the Connection
If everything is set up correctly, you'll see:
In MT5
A status panel will appear in the top-right corner of your chart showing:
- Connection Status: "Connected" with a green indicator
- Broker: Your broker's name
- Account: Your account number
- Balance & Equity: Current account values
- Last Sync: Time since last successful sync (should update every 5 seconds)
In Agentic Traders
- Go to your agent's dashboard
- You should see an "MT5 Connected" badge
- The agent's portfolio will now show your real MT5 balance and positions
Congratulations! Your agent is now connected to MT5. When your agent makes a trading decision (BUY or SELL), the signal will be sent to the EA and executed on your account automatically.
Troubleshooting
EA shows "Disconnected" or "Error"
- Check your API key: Make sure you copied it correctly with no extra spaces
- Check the Agent ID: Verify it matches the agent you want to connect
- Check WebRequest settings: Ensure
https://app.agentictraders.iois in the allowed list - Check your internet connection: MT5 needs a stable connection to communicate
Trades aren't executing
- Is Algo Trading enabled? The button in the toolbar should be green
- Is "Enable Trading" set to true? Check the EA settings
- Is "Allow Algo Trading" checked? Check the EA's Common tab settings
- Check the Experts tab: Go to View → Toolbox → Experts to see any error messages
EA doesn't appear in Navigator
- Make sure you placed the
.ex5file in the correct folder:MQL5/Experts - Right-click on Expert Advisors in Navigator and select Refresh
- Try restarting MT5
Signal was sent but trade didn't open
- Check your account's free margin—you may not have enough for the trade
- Check the symbol is available on your broker (some have different naming like "EURUSDm")
- Look at the Experts log for any error messages from the EA
Security Best Practices
Your API key gives access to execute trades on your behalf. Keep it secure:
- Never share your API key with anyone
- Generate separate keys for different purposes
- Revoke unused keys from the Settings page
- Use demo accounts first to test the integration
- Start with small position sizes when going live
What Happens When You Disconnect
If you stop the EA or disconnect MT5:
- Your agent will detect the disconnection within 60 seconds
- Trading signals will pause until the connection is restored
- Your agent won't make blind trades without knowing your current positions
- All pending signals expire after 5 minutes if not delivered
To reconnect, simply restart the EA or reattach it to a chart.
Next Steps
Now that your agent is connected to MT5:
- Configure your trading strategy to match your risk tolerance
- Add indicators to improve your agent's analysis
- Monitor your agent's performance on the dashboard
- Consider setting up alerts for trade notifications