An Expert Advisor (EA) is a program that runs inside a trading terminal — most commonly MetaTrader 4 or MetaTrader 5 — and follows a fixed set of rules. It can read prices and indicators, open and close positions, move stop-losses and manage orders without a person clicking the buttons. MetaTrader 4 EAs are written in MQL4, MetaTrader 5 EAs in MQL5.
The idea is simple: if a trading approach can be described precisely enough, a computer can execute it consistently, around the clock, without hesitation or fatigue. What the computer cannot do is make a weak idea good.
How an EA is built
Almost every EA, however it is marketed, contains the same building blocks:
- Entry logic — the conditions that trigger a trade, for example a moving-average crossover, a breakout of a range, or a signal from a statistical model.
- Exit logic — stop-loss, take-profit, trailing stop, time-based exit or an opposite signal.
- Position sizing — how large each trade is, either a fixed lot or a percentage of the account balance.
- Filters — spread limits, trading-session windows, news filters and limits on the number of open positions.
- Housekeeping — error handling, reconnection, slippage limits and logging.
Common EA families
| Type | Basic idea | Typical weakness |
|---|---|---|
| Trend-following | Buys strength, sells weakness, aims to ride long moves. | Many small losses in sideways markets. |
| Mean reversion / range | Fades moves away from an average, expects a return. | Large losses when a range breaks into a trend. |
| Breakout | Trades the break of a session high/low or volatility band. | False breakouts, sensitivity to spread and slippage. |
| Scalping | Very short holding times, small targets. | Highly dependent on execution quality and costs. |
| Grid | Places orders at fixed intervals above and below price. | Exposure can grow quickly in a one-way market. |
| Martingale | Increases size after a loss to recover it with one win. | A long losing streak can wipe out the account. |
What an EA does well
- Executes the same rules every time, without emotion.
- Monitors many pairs and timeframes at once.
- Makes a strategy testable: rules in code can be backtested; vague “feel” cannot.
What an EA cannot do
- Adapt to market conditions its rules were never designed for.
- Guarantee anything about future results — markets change, and so do spreads, liquidity and volatility.
- Remove the need for supervision. Platforms freeze, connections drop, brokers change conditions.
Next: what “AI” really means in an EA.