Skip to content
PipsMorrow

A forex expert advisor, usually shortened to EA, is a program that places and manages trades for you on the MetaTrader platform. It follows rules written in code, so it never gets tired, hesitates or skips a setup. It also never questions whether the rules were any good.

This article explains what a forex EA is, how an MT5 EA runs, what automation genuinely improves, and the ways it fails. It makes no claims about profit, because an EA is only a faster way of executing whatever idea you give it.

Key takeaways

  • A forex expert advisor is a program running inside MetaTrader that reads price data, applies fixed rules and sends orders to your broker. It executes a strategy; it does not create an edge.
  • An EA removes hesitation, missed setups and rule-bending. It cannot judge news, a changed market or whether its own rules still make sense.
  • Fixed-lot sizing is a common trap. A 0.10 lot on EUR/USD risks $20 with a 20-pip stop but $100 with a 100-pip stop, which is 4.17% of a $2,400 account.
  • An EA stops when the terminal, the computer or the connection stops. It also trades at live spreads, which are wider than most tests assume.
  • Test in this order: written rules, backtest with costs, forward test on a demo account, then tiny live size. Skipping a stage is how most EAs fail.
  • Buying a ready-made EA means trusting someone else's rules and their reported results. Building your own means you at least know what it does.

What a forex expert advisor is

An expert advisor is a small program that lives inside the MetaTrader terminal (the trading platform most retail forex brokers offer). In MetaTrader 5 it is written in a language called MQL5. You attach it to a chart, and from then on it watches that chart's price and acts on it.

Inside, an EA is a set of if-then rules. If price closes above the 50-period moving average and the spread is below a limit, then open a buy position of a calculated size with a stop loss (the price where the idea is proven wrong) at a set distance. The program has no opinion. It checks the conditions and acts.

People also call this a forex robot, a trading bot or an automated strategy. The words differ but the idea is the same: rules first, then code. If you have not yet written your rules in plain language, start with the lesson on turning an idea into written rules, because an EA cannot rescue a vague idea.

How an MT5 EA runs

An MT5 EA is a loop. Each time a new price tick arrives, the program wakes up, reads the market and your open positions, decides whether any rule fires, and sends an instruction to your broker's server. Then it waits for the next tick.

A loop of four boxes: new tick arrives, EA checks its rules, EA sends an order to the broker, broker fills or rejects it, then back to the next tick
Every tick, the EA runs the same loop. The broker, not the EA, decides whether the order fills and at what price.

Setting it up follows a fixed path. You write or download the source file (extension .mq5), compile it in MetaEditor, which turns it into a runnable .ex5 file, and drag it onto a chart. You then switch on the Algo Trading button in the terminal toolbar. If that button is off, the EA is loaded but cannot place trades.

Three details trip up new users. An EA runs on the chart and symbol it is attached to, so one EA on EUR/USD does not watch gold. It only works while the terminal is open and connected. And a hedging account (which allows opposite positions on one symbol) and a netting account (which merges them into one) can behave differently, so the code has to match your account type.

The MT5 Strategy Tester is the built-in way to replay an EA on historical data. It offers several modeling levels, from every tick to bars only. Faster modes are less accurate on short-term logic, so choose the mode that matches how precise your rules are. The article on backtesting trading strategies covers how to run a test without fooling yourself.

What an EA does better than you

Automation earns its place because it fixes the execution problems that are about people, not markets. These are real benefits, and they are the whole case for building one.

  • Consistency. The same rules apply on trade 1 and trade 200. It does not widen a stop because it "has a feeling".
  • No emotion after a loss. It cannot revenge trade, which makes it a useful guard against the pattern described in revenge trading.
  • Coverage. It watches the chart during hours you are asleep or at work, including the quiet session handoffs you would miss.
  • Speed. It reacts within milliseconds of a condition being met, and it can manage several exits at once.
  • Testability. Because the rules are code, you can replay them on years of history and count every trade. Discretionary trading is far harder to test.

Notice what this list does not say. Nothing in it says the trades will be profitable. Consistency applied to a losing idea produces consistent losses, only faster and with less drama.

What an EA cannot do

The limits matter more than the benefits, because they are where money is lost. An EA is blind to anything you did not put into its rules.

  1. It cannot read the news. A central bank decision or a jobs report can move price hundreds of pips in minutes. Unless you coded a filter that stops trading around scheduled releases, the EA trades straight through them.
  2. It cannot notice that the market changed. A rule that suits a trending market can lose steadily in a range. The EA keeps taking the signals, because noticing a regime shift is a judgment it does not have.
  3. It cannot guarantee the fill price. Orders slip, especially in fast markets. The lesson on execution, slippage and requotes explains why the price you request is not always the price you get.
  4. It cannot turn a weak idea into a strong one. Code only makes an idea precise. If the idea has no edge, automation executes the lack of edge.
  5. It cannot manage you. If you switch it off after three losses and back on after a win, you have recreated discretionary trading with extra steps.
Two columns: what the EA handles (repeating rules, watching the chart, sending orders) and what stays with you (the idea, news, risk limits, checking it still works)
Automation moves the clicking to the machine. The judgment stays with you.

Position size is where EAs often go wrong

Many simple EAs ship with a fixed lot setting (a lot is a standard trade size; one standard lot is 100,000 units of the base currency). Fixed lots are easy to code and quietly dangerous, because the dollars at risk depend on the stop distance, which changes with the market.

Take the site's usual example: a $2,400 account and a goal of risking 1% per trade, or $24. An EA trades EUR/USD at a fixed 0.10 lot, where each pip (the standard unit of price movement, 0.0001 on this pair) is worth about $1. See what that does as the stop distance changes.

EUR/USD at $1 per pip per 0.10 lot. Risk-based lots are rounded down to 0.01, which is why the loss can sit slightly under $24.
Stop distanceLoss at fixed 0.10 lotShare of $2,400Lot size for 1% riskLoss at that size
20 pips$200.83%0.12 lots$24
50 pips$502.08%0.04 lots$20
100 pips$1004.17%0.02 lots$20
Bar chart of dollars lost at a stop hit with a fixed 0.10 lot: $20 on a 20-pip stop, $50 on a 50-pip stop, $100 on a 100-pip stop, against a $24 line for 1% risk
With a fixed 0.10 lot, the loss grows with the stop distance. Only the 20-pip stop stays under the $24 limit.

A well-built EA calculates its lot size from the account balance and the stop distance on every trade, as in how to size a position. You can check any figure yourself with the lot size calculator. Also build in a daily loss limit and a cap on open positions, so a bug or a bad run cannot empty the account in a day.

Watch for martingale and grid logic

Some EAs double the lot size after each loss or keep adding to losing positions. This can produce a long run of small wins and then one loss big enough to trigger a margin call. If you cannot explain exactly how much the worst case loses, do not run it.

Why an EA that tested well can fail live

Most disappointing EAs share a few causes. None is a software fault. They are failures of testing and assumptions.

  • Overfitting. The settings were tuned until the past looked good, so the EA learned the noise of that data. The lesson on over-optimization and curve fitting shows how to spot it.
  • Missing costs. A test that assumes a tight, fixed spread overstates results. Live spreads widen around news and at rollover, and what is spread in forex explains why that hits small-stop systems hardest.
  • Poor test data. Low-quality or gappy history produces trades that never could have happened.
  • Changed conditions. Volatility, trends and spreads shift over time, and a rule set fitted to one period may fade in the next.
  • Technical downtime. A closed laptop, a dropped connection or a terminal restart means the EA is not managing a position that is still open. Many users run MetaTrader on a virtual private server (a remote computer that stays on) for this reason.

Selling points like "fully automated" or "works on any pair" say nothing about any of these. Treat a ready-made EA with the same suspicion you would give a stranger's strategy: ask for the rules in plain language, how costs were modeled, and whether the results come from live trading or only from a backtest. A screenshot proves very little.

Building your own EA the safe way

The most reliable way to understand an EA is to build one from rules you wrote. You do not need to be a programmer to start. The EA builder on this site walks you through seven steps (style, market, entry, filters, exit, risk and review) and produces an MT5 source file you can read, compile and test.

It is an educational tool. It turns your rules into code, but it does not know whether those rules make money, and nothing it produces is a recommendation to trade. Treat the file as something to study and test, not as a finished product.

A four-step ladder from written rules to backtest with costs to demo forward test to tiny live size, with the note that failing a step sends you back down
Each stage tests something the one before it cannot. A failed stage sends you back, not forward.
  1. Write the rules in plain language. Entry, stop, exit, size, the pair and the timeframe.
  2. Build the EA from them and read the code or the summary until you can explain each line.
  3. Backtest with realistic costs in the Strategy Tester, on data the rules were not tuned on.
  4. Forward test on a demo account for weeks. The lesson on forward testing and the limits of demo covers what demo can and cannot show.
  5. Go live only at a very small size, with a daily loss limit, and compare the live numbers with the tests.

Check your drawdown limits before any live run. The drawdown calculator shows how much a given losing run takes off an account, and a worst case you could not stomach is a reason to cut the size, not to hope.

Frequently asked questions

What is a forex expert advisor?

It is a program that runs inside MetaTrader, reads price data, applies fixed rules and sends buy or sell orders to your broker automatically. It can also manage open positions by moving stops or closing trades. It follows the rules it is given and does not judge whether they are sound.

Is an MT5 EA the same as a forex robot?

Yes, in practice. Forex robot, trading bot, forex EA and automated strategy all describe a program that trades by rules. "MT5 EA" only says that it was written for MetaTrader 5, in MQL5. An MT4 version would use a different language and file type.

Can I use an expert advisor without coding?

You can run an existing EA by attaching it to a chart, and you can generate one from a form such as the EA builder. Either way, you remain responsible for understanding the rules. Running code you cannot explain means you cannot tell a bug from a bad market.

Does an EA need to run all the time?

It only works while the terminal is open, connected to the broker and with Algo Trading switched on. If the computer sleeps or the connection drops, the EA stops managing positions. Some traders use a virtual private server to keep the terminal running, which adds a small cost and a setup step.

Are expert advisors safe for beginners?

They are not safer than manual trading, only faster. A beginner with an untested EA can lose money quickly and repeatedly. Learn the basics first, test on demo, use small size and a daily loss limit, and only trade money you can afford to lose.

The PipsMorrow Team

A team of writers covering XAU/USD gold trading education. We focus on explaining the mechanics and risk management in a structured way, with no trade signals and no promotion of any specific broker.

Last updated

Keep reading

Related articles

Ready for the structured path

Build on this article with the full gold trading curriculum, ordered from the basics to advanced topics, free.

See the full curriculum →