What Is an Expert Advisor (EA) in MT4/MT5?
Published July 18, 2026 · Updated November 17, 2026 · In Bot Development
MetaQuotes, the company that makes MetaTrader, defines an expert advisor in one line of its MQL5 reference: “an automated trading system linked to a chart.” In practice, an EA is a small program that watches the price on that chart, checks your rules, and sends orders to your broker without a click from you.
The definition leaves out what happens between a new price and an order: which function MetaTrader calls, which ticks the EA never sees, and why a successful OrderSend call is not yet a trade. MetaQuotes documents each of those steps.
On this page
What is an expert advisor, in plain words?
Picture a trading rule you could write on an index card. Buy when the 20-period average crosses above the 50, risk 1% of the balance, and put the stop under the last swing low.
An EA is that card turned into code. It applies the rule every time the price moves, at 3 a.m. as readily as at noon.
You attach it to one chart, and from then on it acts alone. It stops when you remove it, close the terminal, or switch accounts. MetaTrader 4 runs EAs written in MQL4, while MT5 runs EAs written in MQL5.
The name is a little misleading, by the way. An expert advisor gives no advice. It does exactly what its code says, including the wrong thing when the code is wrong.

EA, indicator, script or service?
MetaTrader runs four kinds of program, and people mix them up all the time. The MQL5 reference separates them by what they are allowed to do:
- An EA sits on a chart, reacts to new prices and can open, change and close trades.
- A custom indicator draws lines, arrows and levels. It can’t send orders.
- A script runs one action once, such as closing every open trade, and then ends.
- A service exists only in MT5. It runs in the background with no chart at all.
Each chart holds only one EA, so if you drop a second EA on the same chart, the first one gets unloaded.
Often an indicator and an EA work as a pair. The indicator spots the setup, and the EA reads its values and places the trade. If you already trade by an indicator, our MT4 and MT5 indicator development page explains how that pairing gets built.

What an EA does on every tick
A tick is a new price quote from your broker. On a busy pair, several can arrive in one second. Every EA is built around a few functions that MetaTrader calls when something happens, and the MQL5 documentation lists them by name.
Start-up: OnInit
When you attach the EA, MetaTrader calls OnInit once. A careful EA reads its inputs here, checks the symbol, and looks for trades it opened before a restart. Each EA also gets its own thread, so two EAs on two charts don’t wait for each other.
The main loop: OnTick
According to the MQL5 reference, OnTick runs in EAs only, when a new tick arrives for the symbol of the chart the EA sits on.
Inside it, the EA asks the same short questions every time. Is the entry condition true right now? Then are the spread, the daily loss, the open trade count and the trading hours all inside my limits?
While OnTick is still busy with one tick, MetaTrader doesn’t queue the ticks that arrive meanwhile. The MQL4 and MQL5 docs both say so. An EA with slow code simply never sees some prices. For a trend system on a one hour chart that hardly matters, but for a scalper it can decide the entry price.
Sending the order: OrderSend
When everything checks out, the EA calls OrderSend in MQL5. The stop loss and target can travel with the order. However, a true result only means the request passed basic checks. MetaQuotes’ documentation states plainly that it “is not a sign of successful execution.” The broker’s answer sits in a return code, and a good EA reads that code and reacts, for example by retrying after a requote or logging why the order was refused.
After the fill: managing the trade
Finally, the same OnTick loop handles open trades. Break-even moves and trailing stops live here, along with partial closes. Many EAs also use OnTimer for jobs that shouldn’t wait for a price change, and OnTradeTransaction to process the result of each trade request.
What an EA can’t do for you
MetaTrader’s help describes EAs as mechanical systems that automate analysis and trading. The rules get followed strictly, without fear or boredom, and the log shows what happened and why. Lot sizes can come from your balance, and daily limits hold even when a tired person would break them.
An EA also has limits:
- A losing strategy stays a losing one. The EA only runs the same rules faster.
- It can’t trade while the terminal is closed or offline, because no ticks reach it.
- Switching off the AutoTrading button blocks every trade request from the EA, closes included. The EA stays loaded and open positions stay open. Stops and targets already on the server still work, but a trailing stop the EA moves itself stops moving.
- It won’t notice news or a broker outage unless someone coded that rule in.
- No EA can promise profit, and no honest seller of an EA claims it can.
MetaQuotes’ help page says that disabling Expert Advisors “only prohibits Expert Advisors from trading.” The button stops the EA from touching your account. It is not a close-all button.

Running an EA in MT4 or MT5
The steps match on both platforms, and MetaTrader’s algo trading help shows each screen.
- Copy the file in. Use File, then Open Data Folder, and drop the EA into MQL4/Experts or MQL5/Experts. After that, refresh the Navigator.
- Drag the EA onto a chart of the symbol it should trade.
- Allow it to trade. Tick the option in its settings, then switch on the AutoTrading button (newer MT5 builds label it Algo Trading).
- Read every input before you press OK, because lot size, risk and limits live there.
- Watch the Experts and Journal tabs. They show what the EA did, or why it did nothing.
Because the EA only reacts to ticks, the terminal has to stay open and online. That is why many traders rent a VPS. MetaQuotes even sells its own virtual hosting, and its help page names the reason: robots and signals need a constant connection to the trade server and steady power. A home laptop that sleeps at night doesn’t qualify.

An MT4 EA won’t run in MT5, and the reverse is also true: the compiled formats (.ex4 and .ex5) differ, and so do the trading functions. Our MT4 vs MT5 guide explains what moving an EA across involves.
Common kinds of EA
Another way to sort EAs is by the job they do. Each type carries its own risks:
- Strategy EAs trade a full system from entry to exit, usually built on indicators.
- Trade managers leave the entry to you, then handle the stop, break-even and partial closes.
- Copier EAs place trades that come from elsewhere, such as a Telegram channel or a TradingView alert.
- Prop firm guards stop trading before a firm’s daily loss line, rather than at it.
- Grid and martingale EAs add trades as the price moves against them. They can look smooth for months, so treat them with real care.
Our own copiers belong to the third group. For example, the Telegram to MT4/MT5 copier reads a channel’s calls, and its EA places, moves and closes the orders in your terminal.

Ready-made or custom expert advisor?
A ready-made EA usually arrives as a compiled file, with no rules you can read. Test it on a demo account for weeks before it touches real money. Our guide to the best forex EA lists the signs of a good one and the red flags.
A custom EA runs your own rules instead. With us, it starts from whatever you have: written rules, an indicator, a TradingView script or marked-up screenshots. Then we ask questions, agree one fixed price before work starts, and test the EA on a demo account first.
You get the source code, the compiled file and plain notes on every input. Read more on MT4 and MT5 EA development, or see how we automate a manual strategy.
Related guides
- MetaTrader 4 automation: where an EA runs on MT4, and what else can automate it.
- MetaTrader 5 automation: MQL5 EAs and Python scripts on MT5.
- Convert an MT4 EA to MT5: what changes when an EA moves platforms.
- More bot development guides: every post on building and running trading bots.
Official MetaQuotes sources
The technical details above come from the MQL5 reference, its pages on OnTick, OrderSend and program running, the MQL4 program running page, and MetaTrader’s help on virtual hosting.
Expert advisor: frequently asked questions
Is an expert advisor the same as a trading robot?
Yes. In MetaTrader, an EA, a forex robot and a trading robot all mean the same thing: a program that trades by itself on a chart.
Does an EA guarantee profit?
No. An EA follows its rules exactly, and that is all. If the rules lose money, the EA loses it faster and more reliably.
Do I need to keep my PC on?
Yes, while the EA should trade. Many traders use a VPS instead, so the EA keeps running when their own PC is off.
Can one EA work on both MT4 and MT5?
Not as the same file. An MT4 EA and an MT5 EA are two separate programs, even when they follow the same rules.
Do I need to code to use an EA?
No. You only need to install it, attach it and set its inputs. To build one, you either learn MQL4 or MQL5 or have a developer write it.
Can an EA trade several symbols?
Yes. Most run one copy per chart and symbol. Others watch several symbols from a single chart, if their code allows it.
Is it allowed to use an EA?
MetaTrader supports EAs out of the box. Even so, your broker or prop firm sets its own rules, so read their terms before you start.
What is the difference between an EA and a signal copier?
A strategy EA makes its own decisions. A signal copier takes decisions from somewhere else, such as a channel, and an EA then places them.
How much does a custom expert advisor cost?
The price depends on the rules and the testing needed. Our pricing page shows a typical starting range, and you get a fixed quote first. Send us your rules to ask.
What is an expert advisor in MT5?
In MT5, an EA is a program written in MQL5 that trades for you on a chart. Its compiled file ends in .ex5 and goes in the MQL5/Experts folder. Once you attach it and switch on Algo Trading, it checks its rules on every tick. Then it can place, change and close trades. The idea is the same as in MT4, but MT4 cannot run the file.
Can I get an expert advisor for MT5 free?
Yes. MT5 ships with sample EAs such as Moving Average and MACD Sample in the Navigator, and the MQL5 Code Base lists more. Treat them as code to learn from, not as a strategy.
Want this built for you?
We develop it as a service — reliable, tested, and yours to own.
Message Us on WhatsApp