What Is an Expert Advisor (EA) in Forex Trading?
Short answer: an Expert Advisor (EA) is a program that runs inside
MetaTrader 4 or MetaTrader 5 and trades automatically by rules. It is written in
MQL4 or MQL5, compiled to an .ex4 or .ex5 file, attached to a chart, and
from then on it reads prices and indicators, opens and closes trades, and manages
stops without you clicking anything.
"Forex robot" and "trading bot" usually mean the same thing. This guide explains how an EA actually runs, how it differs from an indicator or a script, and the four ways to get one.
How does an Expert Advisor work?
An EA is event-driven. MetaTrader calls functions in it when something happens:
| Event | When it fires | Typical use |
|---|---|---|
OnInit | When the EA is attached or the terminal restarts | Create indicator handles, check inputs |
OnTick | On every new price quote for the chart's symbol | Check conditions, open or manage trades |
OnTimer | On a schedule you set | Periodic checks independent of ticks |
OnDeinit | When the EA is removed or the chart closes | Clean up |
Most strategies live in OnTick. Many check whether a new candle has formed
first, so that decisions are made once per closed bar rather than dozens of
times a second — this is what the "OnNewCandle" event in a visual builder
does.
For an EA to trade, three switches must all be on: the terminal's Algo Trading button (called AutoTrading in MT4 and in older MT5 builds), the EA's own "Allow Algo Trading" setting, and your account must permit automated trading. If any is off, the EA runs but cannot place orders — the single most common reason people think their EA is broken.
Expert Advisor vs indicator vs script
| Program | Can trade? | Runs | Use it for |
|---|---|---|---|
| Expert Advisor | Yes | Continuously, on events | Automated strategies and trade management |
| Indicator | No | On every price update | Calculating and drawing values on a chart |
| Script | Yes | Once, then stops | One-off actions such as "close all trades" |
| Service (MT5 only) | Yes | Independently of any chart | Background tasks such as custom data feeds |
An indicator cannot open a trade, which is why "turn my indicator into an EA" is
such a common request. The EA calls the indicator — built-in ones through
functions such as iRSI or iMA, your own through iCustom — and acts on its
values. We explain how in
using your own custom indicator in an Expert Advisor.
What can an EA do?
Anything a trader can do in the terminal, repeatably:
- Enter on conditions — an RSI below 30, a moving-average crossover, a breakout of the previous high.
- Exit by stop loss, take profit, trailing stop, opposite signal or time.
- Size each position from account balance and stop distance instead of a fixed lot. Here is how.
- Filter trades by spread, volatility, or the number of positions already open.
- Protect the account with equity or drawdown limits.
What can't an EA do?
- It cannot find an edge. It executes the strategy you give it, good or bad.
- It cannot run on the MetaTrader mobile app. EAs need the desktop terminal running — on your computer or a VPS.
- It cannot guarantee live results match the backtest. Spread, slippage and fills differ. See our honest answer on making money with a trading bot.
How do you get an Expert Advisor?
- Buy one. Fast, but you inherit someone else's logic, usually as a compiled file you cannot inspect.
- Hire a developer. Good for complex strategies; expect to pay per revision.
- Code it yourself in MQL. Full control, and weeks of learning — MQL4 and MQL5 are different languages.
- Build it visually. Assemble the rules as a graph and export real MQL source. That is what TradeSmithy does; the walkthrough is here.
Build your first Expert Advisor
If you can describe your entry and exit in a sentence, you can build it.
Start free on TradeSmithy: pick a template, change the rules on the
canvas, and export an .mq4 or .mq5 you compile in MetaEditor like any other
EA. The Free plan includes the full builder and one export a month;
Pro adds the AI assistant and server-side backtests.
Frequently asked questions
Is an Expert Advisor the same as a trading bot?
Yes. Expert Advisor is MetaTrader's name for an automated trading program; trading bot and forex robot describe the same thing.
Do Expert Advisors work on both MT4 and MT5?
Each EA is written for one. An MT4 EA (.ex4) will not run on MT5, and vice
versa. A builder that generates both languages lets you target either.
Do I need to leave my computer on for an EA to work?
Yes, the terminal must be running and connected. Traders who run EAs full time usually use a VPS.
Are Expert Advisors allowed by brokers?
Most brokers allow them. Some restrict specific techniques such as latency arbitrage or very high-frequency scalping, so check your account terms.
Keep reading
Best Expert Advisor Builders in 2026, Honestly Compared
fxDreema, EA Builder Pro, EA Studio, StrategyQuant X, the MQL5 Wizard, ChatGPT and TradeSmithy compared on what each builds, exports, tests and costs.
7 min readHow to build a MetaTrader Expert Advisor without writing MQL
A node graph is a program. Here is what each node type does, how the connections become code, and what you get when you press export.
4 min readWhy Is My EA Not Trading? A 12-Point MT5 and MT4 Checklist
The EA is attached, the market is moving, and nothing happens. Twelve causes in the order worth checking, with the MT5 and MT4 error codes that name each one.
4 min read