What is an EA (Expert Advisor)?
Education only, not financial advice. Trading with leverage can lose money fast, sometimes more than you deposit.
An Expert Advisor, or EA, is a program that trades for you inside MetaTrader. It follows fixed rules without fear, greed or sleep. That is its strength and its weakness: an EA will follow bad rules just as faithfully as good ones. This guide explains how EAs work, the main types, how to read the evidence behind them, and how to run one without betting the account on a sales page.
Key takeaways
- An EA is a program (.ex5 file for MT5) that reads prices and opens, manages and closes trades by fixed rules.
- It only works while MetaTrader is running with Algo Trading switched on, which is why many people use a VPS.
- Backtests are easy to over-fit. Forward tests and verified live accounts are much stronger evidence.
- Martingale and grid EAs can show smooth profits for months, then lose most of an account in one move.
- Most EAs lose money over the long term. Judge any EA by worst drawdown, costs and live results, then start on demo or a cent account.
What an EA is
MetaTrader 4 and 5 include a programming language, MQL4/MQL5. An Expert Advisor is a program written in it that is attached to a chart and reacts to each new price (a “tick”). It can do anything a trader can do with the mouse: open trades, set stops and targets, move stops, close trades and show information on the chart.
| Program type | What it does | Trades for you? |
|---|---|---|
| Expert Advisor (EA) | Opens, manages and closes trades by its rules | Yes |
| Indicator | Draws lines or values on the chart (e.g. moving average, ATR) | No |
| Script | Runs once, e.g. “close all trades” | One action only |
| Utility / panel | Helps you trade by hand (e.g. a dashboard, risk calculator) | Only when you click |
How an EA runs in MT5
- The EA file (
.ex5) goes in the MQL5/Experts folder (File → Open Data Folder). - You drag it from the Navigator onto a chart of the symbol it trades, on the timeframe its manual specifies.
- You set its inputs (risk mode, lot or risk %, session filters, magic number) and tick Allow Algo Trading.
- The Algo Trading button on the toolbar must be green. A small hat or icon in the chart corner shows the EA is active.
- The Experts and Journal tabs in the Toolbox show what the EA is doing and any errors.
The main types of EA
| Type | Idea | Typical results | Main risk |
|---|---|---|---|
| Trend-following | Buy strength, sell weakness, ride moves | Many small losses, a few big wins | Long flat or losing periods in ranges |
| Mean-reversion / range | Fade moves back to an average | Many small wins | A strong trend can produce a large loss |
| Breakout / session | Trade the break of a range, e.g. the Asian session high/low | Bursts of activity at session opens | False breakouts, spreads at the open |
| Scalper | Many tiny trades | High win rate, thin edge | Costs, slippage and broker differences eat the edge |
| Grid / recovery | Add trades at set distances, close the basket in profit | Smooth equity, until it isn't | Deep drawdowns in one-way moves |
| Martingale | Increase size after losses | Very high win rate | A losing streak can wipe the account |
Before you run any EA, find out which of these styles it uses; a good product page explains its style and its risks.
Backtests, forward tests and live results
A backtest runs the EA over past prices in MT5's Strategy Tester. It is fast and useful, but it is easy to tune an EA until the past looks perfect. That is called curve fitting or over-optimisation: the settings memorise history instead of capturing a real edge.
A forward test runs the EA on a demo account in real time. A live verified account (for example tracked by Myfxbook with real money) is the strongest evidence, especially over many months with losing periods shown. See how to backtest an EA in MT5.
| Number | What it tells you | Rough guide |
|---|---|---|
| Maximum drawdown | The worst fall from a peak | Ask: could I live with double this? |
| Profit factor | Gross profit ÷ gross loss | Below 1.2 is fragile after real costs |
| Number of trades | How much evidence there is | Hundreds are better than dozens |
| Expectancy | Average profit per trade after costs | Must be clearly above zero |
| Consistency | Results by year and by month | Profits shouldn't come from one lucky period |
Expectancy: will the rules make money on average?
Every EA, however clever, boils down to how often it wins, how much it wins, how much it loses, and what each trade costs.
Expectancy = (win rate × average win) − (loss rate × average loss) − costs per trade
A 55% win rate that still loses
An EA wins 55% of trades. Average win $40, average loss $45, costs $3 per trade.
Winning more often than losing is not enough. The size of wins and losses, and costs, decide the result. Change the numbers below to see what an EA needs.
For learning only. Brokers differ in contract sizes and rounding, so always check your broker's contract specification.
Why martingale and grid EAs are dangerous
A martingale EA doubles its size after each loss, so one win recovers everything. It feels unbeatable because most sequences end in a win. The maths says otherwise.
The cost of a losing streak
Start at 0.01 lot on EUR/USD with a 10-pip stop ($1 risk). Double after each loss.
Grid EAs work differently but share the weakness: in a long one-way move they keep adding positions, and the open loss grows faster than the account. Many show a beautiful equity curve right up to the day they don't. If you run one, use strict account-level loss limits and treat the deposit as fully at risk.
Red flags when buying an EA
- Promises of fixed monthly returns (“10% a month guaranteed”).
- Only backtests or screenshots, no verified live account.
- Live results that begin recently, or that hide drawdown by showing balance only.
- No stop losses, or martingale/grid logic not disclosed.
- Pressure to buy now, “only 3 copies left”.
- Requests to trade through a specific unregulated broker or to send money to a person.
- No manual explaining inputs and risks.
Your first EA: a safe 90-day plan
Excitement is the enemy of a new EA. A slow, staged start costs a little time and can save a lot of money.
Writing down your stop rule
You start an EA on a $1,000 account. Its backtest showed a maximum drawdown of 18%.
Write the numbers down before you start. A rule you set while calm beats a decision made in the middle of a losing week.
Going deeper: notes for experienced traders
- Walk-forward testing: optimise on one period, test on the next unseen one, and repeat. Settings that only work in-sample are curve-fitted.
- Monte Carlo: reshuffle trade order and vary spreads and slippage to see a range of drawdowns rather than one lucky path.
- Broker sensitivity: scalpers and news EAs can behave very differently across brokers due to spreads, execution and stop levels. Test on the broker you will use.
- Every tick based on real ticks in the MT5 tester is the most realistic mode; check the tester's spread settings and add commission.
- Licensing and updates: sale EAs are usually locked to an account number; keep your licence details and update logs.
Common mistakes
- Believing a perfect backtest. It is often curve fitting. Look for forward and live results.
- Running an EA on a laptop that sleeps. Trades stop being managed. Use a VPS for 24/5 EAs.
- Ignoring how the EA handles losses. Martingale and grid logic can turn a normal bad week into a disaster.
- Starting with real money and full risk. Demo, then cent, then small. Increase only after months of evidence.
- Judging by win rate. A 90% win rate with rare huge losses can still lose money.
- Running several EAs without a total risk limit. Their worst periods can arrive at the same time.
Printable checklist
- I know what style the EA trades and how it handles losing trades.
- I checked its worst drawdown and could accept double it.
- I saw forward or verified live results, not only backtests.
- I backtested it myself with real ticks and my broker's costs.
- It uses hard stops on the server, or I understand why it doesn't.
- It runs on a VPS or a computer that stays on.
- I started on demo or a cent account.
- I wrote down the loss at which I will switch it off.
Frequently asked questions
Do EAs really work?
Some make money for a while, and a few for a long time. Most lose over the long term, especially after costs. Treat any EA as a high-risk tool and judge it by live evidence.
Can I run an EA on a Mac or phone?
EAs run in the desktop MetaTrader terminal. Mobile apps can't run EAs. On a Mac you can use MT5's Mac version or, more reliably, a Windows VPS.
Do I need a VPS?
If the EA must run 24 hours a day, five days a week, a VPS is the reliable way. If your EA only trades a few hours and your computer stays on, you may not need one.
What is a magic number?
An ID the EA stamps on its trades so it only manages its own positions. Each EA (and each copy on the same symbol) should have a different one.
Are EAs legal?
Yes. Brokers that offer MetaTrader generally allow EAs, though some restrict certain strategies such as high-frequency scalping. Check your broker's terms.
How do I know if an EA's results are real?
Look for a third-party verified live account with a long history, showing equity (not just balance) and drawdown. Be wary of screenshots.
Sources and further reading
- MetaTrader 5 Help: algorithmic trading and Expert Advisors
- MetaTrader 5 Help: Strategy Tester
- MQL5 Reference: order magic number (ORDER_MAGIC)
- Pips & Gold: How to backtest an EA in MT5
- Pips & Gold: Drawdown explained
This guide is general education, not financial advice. Broker terms differ; always check your own broker's contract specifications.