How to Set Up an Expert Advisor on MT5: A Step-by-Step Guide for Algo Traders

A step-by-step guide to setting up an Expert Advisor on MT5 for algorithmic traders.

Fabian Medhurst

By 

Fabian Medhurst

Published 

Apr 30, 2026

How to Set Up an Expert Advisor on MT5: A Step-by-Step Guide for Algo Traders

Table of Contents


If you run automated strategies, the quality of your broker's MT5 environment matters as much as the EA itself. Slow execution, platform downtime, or wide spreads will degrade any algo's performance before it even has a chance to prove itself.

This guide walks you through every step of setting up an Expert Advisor on MetaTrader 5 — from installing the file to running a backtest and going live. Whether you're deploying a scalping bot or a multi-session trend EA, the process is the same.


What Is an Expert Advisor on MT5?

An Expert Advisor (EA) is an automated trading program that runs inside MetaTrader 5. It follows a defined set of rules to open, manage, and close trades without you manually clicking. EAs can range from simple moving average crossover systems to complex multi-symbol algos with dynamic position sizing.

MT5 supports EAs written in MQL5, the platform's native programming language. You can build your own, purchase one from the MQL5 marketplace, or use a third-party EA compiled as a .ex5 file.


What You Need Before You Start

Before touching any settings, make sure you have:

  • MetaTrader 5 installed — download directly from your broker or the MetaQuotes website
  • Your EA file — this will be a .ex5 file (compiled) or .mq5 file (source code)
  • A funded or demo account — always test on demo first
  • Your broker's MT5 server credentials — server name, login, and password

If you're trading with Spec Markets, MT5 is the native platform. You can open a demo or live account at specmarkets.com and connect in minutes. Both the Raw Zero and Pure Spread accounts support full EA and algo trading.


Step 1: Install Your EA File into MT5

MT5 stores EA files in a specific data folder. Here's how to get your file into the right place:

  1. Open MT5 and go to File > Open Data Folder
  2. Navigate to MQL5 > Experts
  3. Copy your .ex5 or .mq5 file into that folder
  4. Return to MT5 and press F5 (or right-click the Navigator panel and select Refresh)

Your EA will now appear in the Navigator panel under Expert Advisors. If you only have a .mq5 source file, open it in the MetaEditor (press F4), then compile it with F7 to generate the .ex5 file.


Step 2: Enable Algo Trading in MT5

MT5 has a master switch for automated trading. If it's off, no EA will execute orders, regardless of its settings.

  • Look at the top toolbar in MT5 for the Algo Trading button (it shows a green play icon when active)
  • Click it to enable automated trading — the button turns green
  • Confirm the button in the Common tab when attaching your EA also says "Allow Algo Trading"

This is one of the most common reasons traders think their EA is broken when it's actually just switched off at the platform level.


Step 3: Attach the EA to a Chart

  1. Open a chart for the instrument you want to trade (e.g., EURUSD, XAUUSD, US30)
  2. In the Navigator panel, find your EA under Expert Advisors
  3. Double-click it or drag it onto the chart
  4. A settings window will open — do not click OK yet

You'll see a small smiley face icon in the top-right corner of the chart once the EA is attached. A happy face means it's active and allowed to trade. A sad face means algo trading is disabled or the EA has an error.


Step 4: Configure EA Settings

The settings window has three tabs: Common, Inputs, and Dependencies.

Common Tab

  • Allow Algo Trading — must be checked
  • Allow Live Trading — check this for real order execution
  • Allow DLL Imports — only enable if your EA specifically requires it

Inputs Tab

This is where your EA's parameters live — lot size, stop loss, take profit, indicator periods, session filters, and anything else the developer built in. Read the EA documentation carefully here.

A few general rules:

  • Start with the developer's default settings on demo before making changes
  • Adjust lot size based on your account balance and risk tolerance, not on what produced the best backtest results
  • Keep a record of every parameter change you make

Dependencies Tab

If your EA relies on external indicators or libraries, they'll be listed here. Make sure all dependencies are installed in the correct MT5 data folders.

Once you're satisfied, click OK.


Step 5: Backtest Your EA with the Strategy Tester

Before risking real capital, run your EA through the MT5 Strategy Tester. Press Ctrl + R or go to View > Strategy Tester.

Key settings to configure:

Setting Recommendation
Expert Advisor Select your EA from the dropdown
Symbol Match the chart you plan to trade
Timeframe Match your EA's intended timeframe
Modelling Every Tick (most accurate)
Date range Minimum 6–12 months of data
Deposit Match your planned live account size
Leverage Match your broker's offered leverage

Run the test and review the Results and Graph tabs. Pay attention to:

  • Drawdown — how far the equity dropped from peak
  • Profit factor — gross profit divided by gross loss (above 1.3 is a reasonable baseline)
  • Total trades — too few trades means the backtest isn't statistically meaningful

Backtesting shows historical performance only. Past results do not predict future outcomes, and live market conditions will differ from historical data.


Step 6: Move from Demo to Live Trading

Run your EA on a demo account for at least two to four weeks in live market conditions before going live. Watch for:

  • Execution slippage compared to backtest results
  • Any errors in the Journal tab (press Ctrl + T to open the Terminal)
  • Unexpected behavior during high-volatility events like NFP or central bank announcements

When you're ready to go live, the broker's execution environment becomes critical. Your EA's logic means nothing if orders fill 300ms late or spreads spike unpredictably during entry signals.

Spec Markets' MT5 environment averages 0.028-second execution with 99.9% platform uptime across 15+ liquidity providers. For scalping EAs and high-frequency strategies, that consistency matters. The Raw Zero account (spreads from 0.0 pips, $3.50 commission per lot per side) is typically the better fit for EAs that open and close positions frequently. The Pure Spread account (spreads from 1.0 pips, no commission) works better for lower-frequency strategies where the per-trade commission would add up.

Open a live or demo account at specmarkets.com to test your EA in a real execution environment with a $50 minimum deposit.


Common EA Setup Mistakes to Avoid

  • Skipping the demo phase — even a well-coded EA needs validation in live conditions
  • Over-optimizing inputs — fitting parameters too tightly to historical data produces curve-fitted results that fail live
  • Ignoring the Journal tab — MT5 logs every EA action and error there; check it regularly
  • Running multiple EAs on the same account without position sizing rules — they can stack overlapping trades and blow up risk exposure fast
  • Not accounting for swap costs — if your EA holds positions overnight, swap rates affect net performance; factor this into your analysis

FAQs

What file format does MT5 use for Expert Advisors?
MT5 uses .ex5 files (compiled EAs). If you have a .mq5 source file, open it in MetaEditor and compile it to generate the .ex5 file before installing.

Can I run multiple EAs on MT5 at the same time?
Yes. You can attach a different EA to each chart window. Each EA runs independently, but they all share the same account balance, so make sure your total position sizing across all EAs stays within your risk limits.

Why is my EA not placing trades even though it's attached to a chart?
The most common causes are: the master Algo Trading button is off, "Allow Algo Trading" is unchecked in the EA's Common settings, the market is closed, or the EA's internal conditions haven't been met. Check the Journal tab for error messages.

How accurate is the MT5 Strategy Tester?
The "Every Tick" modelling mode is the most accurate option available. However, backtests use historical bid/ask data and cannot fully replicate live spread variations, slippage, or liquidity gaps. Always validate on demo before going live.

Does Spec Markets support all types of EAs, including scalping bots?
Yes. Spec Markets supports full EA and algo trading on MT5, including scalping strategies. The Raw Zero account's 0.0 pip spreads and 0.028-second execution make it well-suited for high-frequency EA strategies.

What is the best account type for running an EA on Spec Markets?
For EAs that trade frequently, the Raw Zero account (spreads from 0.0 pips, $3.50 commission per lot per side) generally produces lower total trading costs. For lower-frequency strategies, the Pure Spread account (spreads from 1.0 pips, no commission) may be more cost-effective.

Can I use a VPS to run my EA 24/5?
Yes, and it's recommended. A VPS keeps MT5 running continuously without depending on your local machine. MetaQuotes offers a built-in VPS option inside MT5, or you can use any third-party Windows VPS service.


Getting your EA set up correctly takes less than 30 minutes. The bigger investment is in testing it properly before you risk real capital. Follow the steps above, respect the demo phase, and choose a broker whose execution environment won't undercut your strategy's edge.

Learn more at specmarkets.com.


Risk disclaimer: Trading CFDs with leverage carries a high level of risk and may not be suitable for all traders. You can lose more than your initial deposit. Past performance of any EA or trading strategy does not guarantee future results. Ensure you fully understand the risks involved before trading live.

Related Posts