What is an Expert Advisor (EA) in MT5?
Definition An Expert Advisor (EA) is a program for the MetaTrader desktop terminal, written in MQL5 for MT5 or MQL4 for MT4, that runs on a chart and can analyse prices and open and manage trades automatically.
An Expert Advisor (EA) is a program that runs on a chart inside the MetaTrader desktop terminal and can analyse prices, open trades and manage them without a click from you; in MetaTrader 5 it is written in MQL5. It works only while that desktop terminal is open and connected, usually on a Windows PC or VPS; the MT5 mobile apps and web terminal cannot run one.
Expert Advisor vs indicator, script and service
MetaTrader 5 runs four kinds of MQL5 program. The MT5 help describes EAs as “mechanical trading systems” and is just as plain about indicators: “Indicators cannot trade.”
| Program | What it is for | How it runs | Folder |
|---|---|---|---|
| Expert Advisor | Analysing and trading | Continuously, attached to a chart | MQL5\Experts |
| Custom indicator | Analysing prices | On a chart | MQL5\Indicators |
| Script | A single action, analytical or trading | Once, on request, then quits | MQL5\Scripts |
| Service | Background tasks such as custom price feeds | Not tied to a chart; can start with the terminal | MQL5\Services |
The MQL5 reference confirms the split for trading: “Trading functions can be used in Expert Advisors and scripts” (MQL5 reference).
How an EA shows up in MT5
- Navigator (Ctrl+N) → Expert Advisors lists the compiled .ex5 files. MetaEditor (F4) compiles source code into them.
- Attaching: drag the EA onto a chart or double-click it. The properties window has a Common tab, with Allow Algo Trading, and an Inputs tab. F7 reopens it later.
- On the chart: “its name and icon appear in the upper right corner of the chart” (MT5 help). The icon shows whether it may trade.
- One per chart: “Only one Expert Advisor can run on one chart. If you start another Expert Advisor on the same chart, the first one is removed.”
- Messages: the Experts tab of the Toolbox (Ctrl+T).
To send orders, an EA also needs algo trading switched on in the terminal. It marks its orders with a magic number, an “Expert Advisor ID” in the words of the MQL5 reference, so it can tell its trades from yours. To talk to a server outside MT5 it uses WebRequest, which works only for addresses you allow in Tools → Options → Expert Advisors.
It only trades while the terminal runs
Hence the forex VPS; see a VPS for an EA. The forex market hours tool shows the sessions in your time zone.
The common mistake
Judging an EA by its promises. Automation does not make a strategy work, and some sellers show returns instead of rules; see forex robot scams. The MT5 help also warns against enabling “Allow use DLL imports” “if you are not sure that launching the application is safe”. Test on demo first: testing an EA on a demo account.
The PipWarden EA
PipWarden connects to your MT5 account through an EA that you attach to one chart. From there it trades every pair you enabled on the dashboard. It manages only positions with its own magic number, leaving manual trades and other EAs alone. Every trade it opens gets a stop loss and a take profit at the broker, and it runs breakeven, trailing stop and partial close inside MT5. Right before an order it checks again, with live data, the open-position cap and any spread limit you set.
It needs MT5 on a Windows PC or VPS, running 24/5, a broker that allows EAs, and the platform address allowed for WebRequest. It cannot run on a phone. The steps are in installing an Expert Advisor in MT5 and on how it works.
Frequently asked questions
Can I run an Expert Advisor on my phone?
What is the difference between .mq5 and .ex5 files?
Educational content, not financial advice. Forex and CFDs are traded on margin and are high risk: you can lose money, and more than your deposit with some brokers. Examples use made-up numbers and show no real results. Read the risk disclosure.