What is an Expert Advisor? A plain guide to EAs in MetaTrader 5
What is an Expert Advisor? It is a program for MetaTrader that follows coded rules to analyse prices and open, manage or close trades on a chart, so the trader does not place each order by hand. People also call it an EA or a trading robot. It follows its rules. It does not predict the market.
Trading forex and CFDs involves substantial risk of loss. Automation applies rules; it does not remove trading risk. Read our risk disclosure.
Key takeaways
- An Expert Advisor (EA) is a MetaTrader program that applies coded rules to price data and can send trade orders by itself.
- In MetaTrader 5 it is written in MQL5 as a .mq5 source file and compiled into an .ex5 file. One chart runs one EA at a time.
- An EA is not an indicator or a script. An indicator draws analysis and cannot trade. A script runs once and stops.
- Two switches must allow trading: the Algo Trading button (AutoTrading in some versions) and the permission in the EA’s own settings.
- An EA runs only while its terminal is running. A backtest or a demo run shows past or simulated behaviour, not a forecast.
What is an Expert Advisor, in one paragraph
An Expert Advisor is software that trades by rule. Its author writes conditions into code, for example when to open a position, how large it should be and when to close it. The program then watches the prices on one chart and acts when its conditions are met. If no condition is met, it does nothing.
MetaQuotes, the company behind MetaTrader, uses three names for the same thing. Its help on algorithmic trading describes automated trading as buying and selling “using special trading robots”, and adds: “In the trading platform, these programs are also called Expert Advisors or EAs.” So Expert Advisor, EA and trading robot mean the same program. Outside MetaTrader, people often say trading bot.
The idea is not specific to one platform. EU financial law defines “algorithmic trading” as trading “where a computer algorithm automatically determines individual parameters of orders such as whether to initiate the order, the timing, price or quantity of the order or how to manage the order after its submission, with limited or no human intervention” (Directive 2014/65/EU, Article 4(1)(39)). An Expert Advisor is the retail trader’s version of that idea: a program decides the order details, inside limits a person set in advance.
How an Expert Advisor runs on a chart
An EA does nothing until you attach it to a chart. The MetaTrader 5 help on Expert Advisors puts it simply: “To start an Expert Advisor, attach it to a chart.” From then on the EA works with that chart’s symbol and timeframe, and the flow below repeats for as long as it stays attached.
- Price data arrives. The broker’s server sends new prices to the terminal.
- The EA checks its rules. Each new price is an event. In MQL5 code it is handled by a function named OnTick, which the MQL5 reference lists as the “NewTick event handler” for Expert Advisors.
- It may send an order request. If the rules are met, the EA asks to open, change or close a position, with a volume and usually a stop.
- The broker’s trade server answers. It accepts or rejects the request. The EA does not fill its own orders.
- The result shows in the terminal. The position appears with your other trades, and the EA’s messages appear in the terminal’s log tabs.
One chart holds one EA. The help on Expert Advisors states: “Only one Expert Advisor can run on one chart. If you start another Expert Advisor on the same chart, the first one is removed.” To run two, open two charts. The guide to running several Expert Advisors on one PC covers that setup.
Expert Advisor vs indicator, script and copy signals
MetaTrader 5 supports three chart-attached program types — Expert Advisors, indicators and scripts — plus account-level copy trading via Signal subscriptions. They are easy to confuse because each automates part of a workflow, yet each has different permissions and runtime rules.
| Type | What it is for | Can it place trades? | How long it runs | Where rules live |
|---|---|---|---|---|
| Expert Advisor (EA) | Automating a trading method: analysis and orders | Yes | Continuously, while attached to its chart | Compiled .ex5 code in your MT5 terminal |
| Indicator | Drawing analysis on a chart, such as lines or signals | No | While attached to a chart. Many indicators can share one chart | Compiled .ex5 code in your MT5 terminal |
| Script | Doing one job on request, such as closing all orders | Yes | Once, then it stops | Compiled .ex5 code run once on demand |
| Copy / Signal service | Mirroring another trader’s orders proportionally onto your account | Yes (copies provider orders) | While subscribed and connected (or on Virtual Hosting) | External signal provider’s trading account |
The MetaTrader 5 help on creating an Expert Advisor or an indicator draws the same lines. Of indicators it says: “Indicators cannot trade and do not have access to charts.” Of scripts it says that “if an Expert Advisor works almost continuously, a script executes its function and quits.” An EA can still read indicator values — or translate chart context such as a Fibonacci golden pocket into fixed entry and invalidation rules — to make its decisions. The MT5 indicators guide covers that side.
How an Expert Advisor is made: MQ5 source and EX5 file
An MT5 Expert Advisor is written in MQL5, the platform’s own programming language, in an editor called MetaEditor. The source code is saved as a .mq5 file, which a person can read and edit. Before the platform can run it, the code is compiled. The MetaTrader 5 help describes pressing F7 to compile, and says of the result: “The executable file has an extension EX5 and can be run in the trading platform.”
- .mq5 file
- The source code. Readable and editable.
- .ex5 file
- The compiled program. This is the file the terminal runs when you attach an EA to a chart.
- Inputs
- Settings the author exposes, such as lot size or a stop distance. You change them when you attach the EA, without touching the code.
Not every EA is written by hand. MetaEditor includes a wizard, and the MetaEditor help says that with it “a trader can develop Expert Advisors even without programming skills.” Some traders instead buy or license an EA from its publisher. Use only EAs you wrote, bought or licensed. For the build routes, see how to make a trading bot and Expert Advisor coding.
What must be switched on before an EA can trade
An attached EA can analyse prices and still be blocked from trading. Two permissions control that, and both must be on.
- The platform switch. This is the toolbar button labelled Algo Trading (AutoTrading in some versions and in the help). The help on Expert Advisors says of it: “If you turn it off, automated trading is disabled for all Expert Advisors even if you enable automated trading individually in the Expert Advisors settings”.
- The EA’s own permission. Each EA has an Allow Algo Trading option in its properties (Allow Auto Trading in some versions and in the help). The help describes it as an option that “limits the trading activities of Expert Advisors”, which is useful when you want an EA to analyse without placing orders.
Your broker’s or firm’s terms matter too, so check what they say about automated trading before you rely on an EA. The guide Is EA allowed in trading? lists where to look, and how to install an EA on MT5 walks through the steps.
Where an Expert Advisor runs, and when it stops
An EA is not a service running somewhere on the internet. It runs inside a MetaTrader terminal, so it works only while that terminal is running. The MQL5 reference lists “terminal shutdown” among the cases in which an Expert Advisor is unloaded. When the terminal closes, the EA stops. Stop Loss and Take Profit levels that are already set are, in the words of the help on executing trades, “stored and executed on the broker’s server”, but the EA decides nothing new.
That is why people who run an EA around the clock keep a desktop on or rent a hosted terminal. The MetaTrader 5 help on virtual hosting describes MetaQuotes’ own option this way: “Virtual hosting is a service providing the round-the-clock operation of the trading platform.” See MT5 mobile and trading robots for what the mobile app can and cannot do.
How to judge an Expert Advisor, and what it cannot do
An EA is only as good as its rules, and rules that worked on past prices can fail on new ones. Three checks come before any real money.
- Read what it does. Find out how it enters, how it sizes positions and what stops a losing run. Trading bot algorithms explains the main families and how each one fails.
- Backtest it. MetaTrader 5 has a Strategy Tester. Its help defines a test as a “single run with fixed parameters using historical price data.” A backtest is a simulation of the past. The Expert Advisor tester guide covers the settings.
- Run it on a demo account. Watch it trade simulated money in current conditions, and keep a record of what it does. How to verify a trading bot explains what each kind of evidence can and cannot show.
Keep the limits in mind. An EA cannot predict prices. It does not get tired or emotional, but it also does not notice that conditions have changed unless its code tells it to. It will keep following its rules through a losing period unless a limit stops it. Automation applies a method consistently. It does not make the method profitable. The same caution applies to listings marketed as an AI expert advisor: read what the publisher says the model actually does rather than assuming a label implies predictive edge.
YO4X is a Windows desktop workspace for supported MetaTrader 5 strategies, bot configuration and trading journals. It does not execute EX5 files or arbitrary uploaded code, so an EA you own runs in MetaTrader itself. The EX5 research directory holds source-based guides to third-party Expert Advisors, each credited to its publisher — for example, the Quantum Titan MT5 setup and risk guide documents one publisher’s stated Gold strategy setup, dated signal evidence and risk notes.
Frequently asked questions
What is an Expert Advisor in forex?
In forex, an Expert Advisor is a MetaTrader program that follows coded rules to place and manage currency trades on a chart. It runs in your own terminal and sends orders to your broker like any other order from that terminal. The same kind of program can trade gold, indices or other symbols if it was written for them.
What does EA mean in trading?
EA stands for Expert Advisor. It is MetaTrader’s name for an automated trading program, also called a trading robot or a trading bot. The MetaTrader 5 help says these programs “are also called Expert Advisors or EAs”.
Is an Expert Advisor the same as an indicator?
No. An indicator analyses prices and draws on the chart, and it cannot place trades. An Expert Advisor is built to trade. An EA can use indicator values in its rules, so the two often work together.
What is the difference between an EX5 file and an MQ5 file?
An MQ5 file is editable MQL5 source code that you can read, inspect and compile in MetaEditor with F7. An EX5 file is the compiled executable program that MetaTrader 5 actually attaches to a chart and runs. Commercial publishers usually distribute only the compiled EX5 file, so you can configure its exposed inputs but cannot inspect its internal source code.
Can an Expert Advisor trade automatically on MetaTrader 5 without my PC on?
Not from a home computer that is shut down or asleep, because an EA runs inside an active desktop MT5 terminal. To keep an EA trading around the clock while your PC is off, traders use MetaQuotes Virtual Hosting or a remote Windows server (see how to compare forex VPS options). The MT5 mobile app lets you check positions and close trades manually, but it does not run desktop Expert Advisors.
What is the difference between an Expert Advisor and an MT5 copy-trading Signal?
An Expert Advisor executes coded rules directly inside your MT5 terminal on a chart, so your terminal decides when to submit orders. An MT5 Signal subscription mirrors trades opened on a signal provider’s external account onto yours proportionally without running local strategy rules on your chart. Both require a running terminal or Virtual Hosting to stay active and carry full account risk.
Do I need to know how to code to use an Expert Advisor?
No. Attaching a compiled EA to a chart and setting its inputs needs no programming. Writing your own EA does, unless you use a wizard or a builder to generate one. Either way, test it in the Strategy Tester and on a demo account before you rely on it.
Can an Expert Advisor guarantee a profit?
No. An EA applies fixed rules, and markets change. A strong backtest shows how those rules behaved on past data under the test’s assumptions. It is not a forecast, and losses can be larger than any test suggested.
Keep reading
- How to install an EA on MT5
- Expert Advisor tester: Strategy Tester settings
- Trading bot algorithms: types and how they decide
- Grid and martingale Expert Advisors: mechanics and risk
- Is an EA allowed in trading?
- YO4X help center
Sources: Algorithmic Trading, Trading Robots - MetaTrader 5 Help · Expert Advisors and Custom Indicators - MetaTrader 5 Help · How to Create an Expert Advisor or an Indicator - MetaTrader 5 Help · Strategy Testing - MetaTrader 5 Help · Executing Trades - MetaTrader 5 Help · Virtual Hosting for 24/7 Operation - MetaTrader 5 Help · MQL4/MQL5 Wizard - MetaEditor Help · Program Running - MQL5 Reference · Directive 2014/65/EU (MiFID II), Article 4 - EUR-Lex
Trading forex and CFDs involves substantial risk of loss. Past performance and backtests do not guarantee future results. Read our risk disclosure before you trade.