Connect Broker

Connect to MetaTrader 5

Execute your agent's trades on a real MT5 broker account

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:

  1. Your agent analyzes the market using the indicators and strategy you configured
  2. When it decides to trade, it sends a signal to our servers
  3. Our EA (Expert Advisor) running in your MT5 terminal receives the signal
  4. The EA executes the trade on your broker account
  5. 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 MetaQuotes

Creating a Demo Account

If you're new to MT5 or want to test the integration:

  1. Open MT5 after installation
  2. Go to File → Open an Account
  3. Search for your broker or select "MetaQuotes Software Corp" for a test account
  4. Choose Demo account and follow the prompts
  5. 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:

  1. Open MT5 and log into your account
  2. Go to File → Open Data Folder (this opens Windows Explorer)
  3. Navigate to MQL5 → Experts
  4. Copy the AgenticTradersEA.ex5 file into this folder
  5. Go back to MT5 and find the Navigator panel (usually on the left side)
  6. 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.

  1. Log into your Agentic Traders dashboard
  2. Go to Settings (gear icon in the sidebar)
  3. Click on the API Keys tab
  4. Click Generate New Key
  5. Give it a name like "MT5 Connection" so you remember what it's for
  6. 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:

  1. Go to your Agents page
  2. Click on the agent you want to connect
  3. Open the agent's Settings tab
  4. 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:

  1. In MT5, go to Tools → Options
  2. Click the Expert Advisors tab
  3. Check the box: "Allow WebRequest for listed URL"
  4. Click Add and enter: https://app.agentictraders.io
  5. Click OK to save

Enable Algorithmic Trading (Required)

The EA needs permission to place trades:

  1. Look at the MT5 toolbar at the top
  2. Find the Algo Trading button (it may say "AutoTrading" in some versions)
  3. Click it so it turns green
  4. 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:

  1. In the Navigator panel, find Expert Advisors → AgenticTradersEA
  2. Drag and drop it onto any chart (the chart's symbol doesn't matter—the EA handles all symbols)
  3. 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 |

  1. Click the Common tab
  2. Make sure "Allow Algo Trading" is checked
  3. 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

  1. Go to your agent's dashboard
  2. You should see an "MT5 Connected" badge
  3. 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.io is 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 .ex5 file 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: