What is an MT5 expert advisor? How a MetaTrader 5 trading robot works, from EX5 files to evaluation
What an MT5 expert advisor is, how it runs inside MetaTrader 5, the difference between EX5 and MQ5 files, and the practical checks that help you judge any EA before you use it.

What an MT5 expert advisor is
An MT5 expert advisor (EA) is a program written in the MQL5 language that runs inside the MetaTrader 5 terminal. It can analyze prices and open, modify or close orders on your account based on rules coded by its developer. An EA is attached to a chart, reacts to market events such as new ticks, and only trades when algorithmic trading is enabled in the terminal.
People also call it a MetaTrader 5 trading robot, an automated strategy or simply a bot. Whatever the name, it is code that follows rules. It does not understand the market and does not adapt beyond what its logic allows. That framing is the most useful one to keep while you read the rest of this guide.
Automate this on MetaTrader 5
A MetaTrader 5 expert advisor with documented inputs, full backtest settings and clear risk limits.
How an expert advisor runs inside MetaTrader 5
An EA lives in the terminal, not on the broker server. That has practical consequences.
It is event driven
MQL5 programs respond to events. The functions you will see named in documentation and in EA descriptions are:
- OnInit: runs once when the EA is attached to a chart or when its inputs change. This is where it reads its settings and checks the environment.
- OnTick: runs when a new price tick arrives for the chart symbol. Most trading logic sits here.
- OnTimer: runs at a fixed interval if the developer set a timer, useful for logic that should not depend on tick flow.
- OnDeinit: runs when the EA is removed, the chart closes or the terminal shuts down.
The tick-driven model matters. On EURUSD during the London session, ticks arrive constantly. On a quiet symbol or outside main hours, an OnTick based EA may sit idle simply because no new price arrived.
It needs the terminal running
If you close MetaTrader 5 or your computer sleeps, the EA stops. Any open positions remain on the account with whatever stop loss and take profit were already sent to the server, but the EA cannot manage them. This is why many traders who run EAs full time use a VPS, either from a hosting provider or the virtual hosting offered inside MetaTrader 5.
It needs permission to trade
Two switches control whether an EA can send orders:
- The Algo Trading button on the main toolbar. When it is off, no EA in the terminal can trade.
- The Allow Algo Trading option in the EA properties window, on the Common tab, which you see when you attach it to a chart.
If an EA loads but never trades, check both before suspecting the code. The MetaTrader 5 help page on algorithmic trading describes these controls. For a walkthrough of the inputs tab, lot size fields and permissions, see the guide on MT5 expert advisor settings for beginners.
One EA per chart
MetaTrader 5 allows one expert advisor per chart window. To run the same EA on EURUSD and on a US index CFD, you open two charts and attach it to each. Each instance has its own inputs, so check them individually.
EX5 vs MQ5 files
This is where many new users get confused, so here is the short version.
| File | What it is | Can you run it? | Can you read or edit the logic? |
|---|---|---|---|
| .mq5 | MQL5 source code | Not directly, it must be compiled | Yes, in MetaEditor |
| .ex5 | Compiled program | Yes, this is what MT5 executes | No, the logic is not readable |
The .mq5 file is the human-readable source. You open it in MetaEditor, the code editor that ships with MetaTrader 5, and compile it to produce an .ex5 file. The terminal runs the .ex5.
Most commercial EAs are delivered as .ex5 only. That protects the developer's work, but it also means you cannot inspect the rules yourself. You rely on documentation, testing and the developer's transparency. Some .ex5 files are also tied to a specific account number or license, so check the licensing terms before you install on a new account.
Where the files go
In MetaTrader 5, open File >> Open Data Folder, then go to MQL5 >> Experts. Copy the .ex5 (or .mq5) file there, then right-click Expert Advisors in the Navigator window and choose Refresh, or restart the terminal. The EA then appears in the Navigator and can be dragged onto a chart. If you only have an .mq5 file, open it in MetaEditor and compile it first. The MetaEditor documentation covers compiling and error messages.
Set files (.set) are a separate thing: they store input values, not code. If your EA comes with them, the guide on how to load an MT5 set file explains how to match them to your EA version.
What an EA can and cannot do
An expert advisor can:
- Send market and pending orders, set stop loss and take profit, trail stops and close positions.
- Read price data on any timeframe and from other symbols available in Market Watch.
- Use built-in or custom indicators as inputs to its logic.
- Apply position sizing rules, for example a fixed lot or a percentage of balance.
An EA cannot:
- Trade a symbol your broker does not offer. Many MT5 brokers offer forex and CFDs on indices or oil rather than exchange futures such as ES, NQ or CL. The EA trades whatever instrument your account provides, with that instrument's contract specifications.
- Protect you from execution reality. Spreads, slippage and requotes on your broker affect results. An EA tuned on EURUSD with a tight spread may behave differently on a wider-spread account.
- Adapt to conditions its rules do not cover. A breakout logic built around normal volatility can behave very differently around high-impact news.
Account mode also matters. MetaTrader 5 supports netting accounts, where one symbol has one aggregate position, and hedging accounts, where several positions on the same symbol can coexist. An EA designed for hedging, such as a grid that opens multiple tickets, may not work as intended on a netting account. Check which mode your account uses and which mode the EA was built for.
How to evaluate an MT5 expert advisor
You do not need to read MQL5 to judge an EA sensibly. Start with these questions.
Is the logic described in plain terms?
You should know what triggers an entry, how exits work, whether a stop loss is always placed and how lot size is calculated. Vague claims about secret or AI-driven logic without a description of risk handling are a warning sign.
Are the inputs documented?
Every input should have a clear purpose and a stated unit: pips, points, lots, percent. Watch for the magic number input, which lets the EA identify its own trades so it does not interfere with manual positions or other EAs.
Does it state the symbol, timeframe and account type it was built for?
An EA described for EURUSD on M15 is not automatically suitable for an index CFD on M1. Point values and typical ranges differ.
What happens in the worst case?
Look at how the EA behaves when it is wrong: maximum lot size, whether it adds to losing positions (martingale or grid behavior), and whether there is a daily or total loss limit. Leverage cuts both ways, and the CFTC's forex fraud advisory is worth reading if a seller promises steady returns.
Can you test it yourself?
Run it in the Strategy Tester on historical data, then on a demo account in real time. A backtest shows how the rules behaved on past data, not what they will do next. The step-by-step guide on how to test an expert advisor in MT5 covers modeling modes and report reading. If you are close to buying, the due-diligence checklist before buying an MT5 expert advisor goes deeper.
If you would rather start from a robot that already ships with documented inputs and set files, an MT5 expert advisor with documented inputs and set files saves you the time of reverse-engineering an undocumented .ex5.
Conclusion
An MT5 expert advisor is compiled MQL5 code that runs on a chart in your terminal, reacts to ticks and timers, and trades only when algorithmic trading is allowed. The .mq5 file is source, the .ex5 file is what runs. Before relying on any EA, understand its rules, its inputs, the account type it expects and how it behaves when wrong, then test it on demo with your own broker's conditions. If you want a documented starting point, take a look at the MT5 expert advisor available from SierraOnShop.
FAQ
Is an expert advisor the same as an indicator in MT5?
No. An indicator calculates and draws values on a chart but cannot place trades. An expert advisor can send and manage orders. An EA may use indicators internally as part of its logic.
Can I run an MT4 expert advisor in MetaTrader 5?
Not directly. MT4 uses MQL4 and .ex4 files, which MetaTrader 5 does not run. The code has to be rewritten or converted to MQL5 and compiled into an .ex5 file.
Does an EA keep trading if my internet drops?
No. The EA needs a live connection to the broker server to send or modify orders. Stops and targets already placed on the server stay active, but new decisions wait until the connection returns.
Where do I see what my EA is doing?
Open the Toolbox window and check the Experts tab, which shows messages printed by the EA, and the Journal tab, which logs terminal events such as connection issues and order errors.
Run it in MetaTrader 5
Written by
Clement
Futures trader for more than seven years, specialized in order book and order flow scalping on US index futures, now building automated strategies. Founder of SierraOnShop.
More about the authorReady to run an expert advisor?
A MetaTrader 5 expert advisor with documented inputs, full backtest settings and clear risk limits.