An expert advisor, usually shortened to EA, is a program that trades for you inside MetaTrader 4 or MetaTrader 5. It watches the market, applies a fixed set of rules and opens, manages and closes trades without you clicking a button. Forex traders often call them trading robots or forex bots.
What an expert advisor is
An EA is written in MQL4 (for MT4) or MQL5 (for MT5), the programming languages MetaQuotes built into the platforms. The developer compiles the code into an .ex4 or .ex5 file, which you copy into MetaTrader and attach to a chart. From then on the EA reacts to every new price that arrives on that chart.
The rules can be as simple as “buy when the 50-period moving average crosses above the 200” or as involved as a multi-timeframe model that filters trades by volatility, session and spread. What every EA has in common is that the decisions are mechanical: the same market conditions always produce the same action.
How an EA works
MetaTrader runs an EA through a small set of events. Understanding them explains most of an EA's behaviour.
- Start. When you attach the EA, it reads its inputs, checks the account and symbol, and prepares any indicators it uses.
- Every tick. Each time a new price arrives, the EA checks its rules. Most EAs only act on a new bar, so a tick in the middle of a candle changes nothing.
- Orders. When the rules line up, the EA sends a market or pending order to your broker with a lot size, stop loss and take profit.
- Management. On later ticks it may move the stop loss, trail profits, close part of the position or add trades, depending on its design.
- Stop. When you remove the EA or close MetaTrader, it stops. Open trades stay open at your broker, with whatever stop loss and take profit they already have.
That last point matters: an EA only works while its terminal is running and connected. Traders who want an EA to trade all week run MetaTrader on a virtual private server close to their broker. Our VPS guide covers how.
Common EA strategies
Most expert advisors fall into a handful of families. Knowing the family tells you more about an EA's risk than its marketing does.
| Strategy | How it trades | What to watch |
|---|---|---|
| Trend following | Buys strength and sells weakness, holding while a move lasts. | Many small losses in ranging markets; profits come from a few long trends. |
| Mean reversion | Fades stretched moves and expects price to return to an average. | High win rate, but a strong trend can produce one large loss. |
| Breakout | Enters when price leaves a range, often at session opens. | False breakouts and slippage around news. |
| Scalping | Takes many short trades for a few pips each. | Very sensitive to spread, commission and execution speed. |
| Grid and martingale | Adds positions as price moves against it, often with larger lots. | Smooth equity until a long trend causes a deep drawdown. Read our grid and martingale guide. |
| News trading | Trades around scheduled economic releases. | Wide spreads, requotes and fast price gaps. |
Settings you'll see
Every EA exposes inputs in its settings window. The names vary, but these show up in almost all of them:
- Lot size or risk percent. A fixed lot trades the same size every time; a risk percent sizes each trade from your balance and stop loss. Our position size calculator shows what a given risk means in lots.
- Stop loss and take profit. In pips or points. Check whether the EA always sets a stop loss: some only close losing trades by their own logic.
- Magic number. An ID the EA stamps on its trades so it doesn't touch trades from you or other EAs.
- Maximum spread. The EA skips trades when the spread is wider than this, which protects scalpers during news and rollover.
- Trading hours and days. Limits trading to the sessions the strategy was built for.
- Maximum open trades. Caps how many positions the EA holds at once, an important brake on grid systems.
Developers often ship preset .set files with tested settings for specific symbols. Loading one is quicker and safer than tuning inputs by hand.
What an EA can't do
An expert advisor removes hesitation and fatigue from trading, but it doesn't remove risk. A few limits apply to every EA, however well it is built:
- It can't adapt beyond its rules. An EA built for a ranging market keeps trading the same way when the market starts trending.
- Backtests flatter it. A strategy tuned on past data can look perfect on that data and fail on new data. This is called overfitting or curve fitting.
- Your broker matters. Spread, commission, slippage and execution speed differ between brokers and change live results, especially for scalpers.
- It can't guarantee anything. Be wary of any EA sold with promised monthly returns. Markets change, and past performance doesn't predict future results.
Before you run one live
A short checklist catches most problems before they cost money:
- Read the documentation: which symbols, timeframe and account type the EA expects, and whether it uses a grid or martingale.
- Backtest it on good data with realistic spreads. Our backtesting guide walks through the strategy tester.
- Run it on a demo account for a few weeks to see how it behaves with your broker's real conditions.
- Decide your risk per trade and your maximum drawdown before you start, and size the EA to fit. The risk of ruin calculator shows how those choices play out.
- Check practical details: hedging or netting account, minimum lot size, symbol suffixes such as
EURUSD.m, and allowed algorithmic trading. - Start live with the smallest size you can, then scale only when live results match the demo.
EA, indicator or script?
MetaTrader runs three kinds of programs, and they're easy to confuse:
| Type | What it does | Trades on its own? |
|---|---|---|
| Expert advisor | Runs continuously on a chart and can open, manage and close trades. | Yes |
| Indicator | Calculates and draws values on a chart, such as moving averages, levels or signal arrows. Some send alerts. | No |
| Script | Runs once when you drop it on a chart, for a single job such as closing all trades. | Only once, when you run it |
Many traders pair an indicator for spotting setups with manual entries, then move to an EA once the rules are clear enough to automate. If you have a strategy you'd like turned into an EA, our custom development service builds it to your rules.