Expert Advisor (EA) Definition: An Expert Advisor (EA) is a program that runs inside the MetaTrader trading platform and opens, manages and closes trades on its own according to rules written in code. Each time a new price arrives, the EA checks its conditions and acts, so its results depend entirely on the strategy it contains and on real trading costs.
What Is an Expert Advisor (EA)?
Think of an EA as a set of trading instructions that has been handed to the software itself. You attach it to a price chart, say EUR/USD on the one-hour timeframe, and from then on the program watches that chart and places orders whenever its conditions are met. It can also move stop levels, close positions at a set time or stop trading after a daily loss.
The name comes from MetaTrader, the desktop platform used by many forex and CFD brokers. MetaQuotes released MetaTrader 4 in 2005 with its own programming language, MQL4, and called the trading programs written in it “Expert Advisors”. MetaTrader 5 followed in 2010 with a new language, MQL5, so EAs built for one version do not run on the other without conversion.
In the broader vocabulary of automated trading, an EA is simply a trading robot that lives inside one specific platform. Outside MetaTrader, the same idea is usually called a bot or an algorithm.
How Does an Expert Advisor Work?
Every EA is built around a few event handlers, blocks of code that fire at set moments. One runs when the EA starts, one when it is removed, and the main one, OnTick, runs on every new price quote. Inside OnTick the EA reads prices and indicator values, checks open positions and sends orders to the broker’s server if its rules say so. User-adjustable inputs, such as lot size or stop-loss distance, let traders change behaviour without editing the code.
Before going live, traders run the EA through the Strategy Tester, a built-in tool for backtesting on historical prices. The tester reports profit, number of trades and maximum drawdown. The weak point is cost assumptions, and a short-term EA shows why.
Take a hypothetical scalping EA on EUR/USD that trades 1 standard lot, where 1 pip is worth $10. Over 500 test trades it captures an average of 1.5 pips before costs. The backtest assumes a 0.5-pip spread, so the net gain is 1 pip per trade, or 500 × $10 = $5,000.
Live trading tells a different story. Spreads widen during news and quiet hours, and fills arrive a fraction of a pip worse because of slippage, so the real cost per trade averages 1.8 pips. Now each trade loses 0.3 pips, and the same 500 trades produce 500 × −$3 = −$1,500. The strategy did not change; only the costs did, and a thin edge per trade could not absorb them.
Types of Expert Advisors
Trend-following EAs buy when price breaks above a level or a moving average and sell on the reverse signal. They make most of their money in sustained moves and give back small amounts in sideways markets.
Scalping EAs aim for a few pips per trade and trade often, which makes them the most sensitive to spreads and execution speed.
Grid and martingale EAs add positions as price moves against them, the martingale version doubling the size each time. Their equity curves often look smooth for months and then suffer a single very large loss.
Trade-management EAs do not open positions at all. They attach stops and targets, trail stops or close trades at set times for a trader who enters manually.
Expert Advisor vs. Trading Bot
An EA and a trading bot do the same job: they turn rules into orders without a human clicking buttons. The difference is the environment. An EA is written in MQL, runs inside a MetaTrader terminal and trades through the broker connected to it, while a bot is usually written in a general language such as Python and talks to an exchange through an API key.
That setup shapes practical use. EAs come with a ready testing tool and a large marketplace of finished programs, which suits forex and CFD traders. Bots are more flexible and common in crypto, but the trader has to build the testing and hosting themselves.
Why Is an Expert Advisor Important for Traders?
An EA removes the gap between plan and action. It enters at the exact level, applies the same position size rule every time and keeps working through the Asian session while the trader sleeps. Writing a strategy as an EA also forces every rule to be precise, because code cannot act on a vague idea like “buy when it looks strong”.
Testing results are the first risk. A trader can adjust inputs until a backtest looks perfect, a habit known as curve fitting, and end up with an EA that describes past noise rather than a lasting pattern. Running the EA on a demo account for several weeks shows how it behaves with real spreads and fills before money is at stake.
Commercial EAs carry a second risk. Sellers often advertise smooth profit curves built from backtests or short live periods, and grid or martingale logic can hide large losses until one bad trend arrives. Checking a long live record, setting a hard maximum drawdown and keeping lot sizes small limit the damage if the EA meets conditions it was never built for.
Key Takeaways
- An Expert Advisor is a program that trades automatically inside MetaTrader, following rules written in MQL4 or MQL5.
- It reacts to every new price tick, checking its conditions and sending, adjusting or closing orders without manual input.
- Backtests in the Strategy Tester can overstate results when they underestimate spreads, slippage and changing market conditions.
- EAs differ from crypto trading bots mainly in platform and language, not in purpose.
- Curve-fitted strategies and grid or martingale logic are the most common reasons EAs fail in live trading.
Do I need to know how to code to use an Expert Advisor?
No. Many traders install ready-made EAs and only adjust input settings such as lot size or stop distance. Writing or changing the strategy itself, however, requires knowledge of MQL4 or MQL5.
Does an Expert Advisor work when my computer is off?
No. An EA runs only while the MetaTrader terminal is open and connected. Traders who want it running around the clock usually host the terminal on a virtual private server, a remote computer that stays online.
Can an Expert Advisor from MetaTrader 4 run on MetaTrader 5?
Not directly. The two platforms use different programming languages, so an MQL4 EA has to be rewritten or converted before it runs on MetaTrader 5.
Why does my EA perform worse live than in the Strategy Tester?
Backtests often assume fixed spreads and instant fills, while live trading includes wider spreads, slippage and requotes. A strategy tuned too closely to past data can also stop working once market behaviour changes.