Automated Trading

What Is an Expert Advisor (EA) in MetaTrader 5?

An Expert Advisor is a program that trades inside the MT5 terminal. How EAs work, what they can and cannot do, where they fail, and how to evaluate one before it touches real money.

By the AURAX teamPublished 5 min read

On this page (6)

An Expert Advisor (EA) is a program written in MQL5 that runs inside the MetaTrader 5 terminal and places, manages and closes trades on its own. It is attached to a chart, reacts to every price tick, and sends orders to your broker exactly as a manual trade would. It trades only while that terminal is open, connected and allowed to trade — which is why EAs usually run on a computer that never sleeps.

EA in one table
What it is
LanguageMQL5, MetaQuotes' C++-like language for MT5
Files.mq5 source code; .ex5 compiled program (what you usually receive)
Where it livesMQL5\Experts in the terminal's data folder
Where it runsIn your MT5 terminal — your PC, a VPS, or a hosted terminal
Who executes the tradesYour broker, through your account, at the broker's prices
EA in one table.

How an EA works

An EA is event-driven. MT5 calls into it when something happens, and the EA decides what, if anything, to do:

  • On start (OnInit): read its inputs, check the symbol and account, set up indicators.
  • On every tick (OnTick): a new price arrived. This is where most EAs evaluate their rules — whether to open, add to, or close positions.
  • On timers and trade events: periodic checks, and reactions to fills, closures and order changes.
  • On stop (OnDeinit): removed from the chart, terminal closing, settings changed.

Inside those events an EA can read prices and indicators, inspect open positions, and send orders. What it cannot do is anything the terminal cannot: it cannot trade when MT5 is closed, cannot bypass the broker's rules, and cannot move money in or out of the account.

What EAs are good at

  • Consistency. The rules run the same way at 03:00 as at 15:00, without fatigue, hesitation or revenge trading.
  • Speed and coverage. Reacting within milliseconds, on every tick, around the clock of a 23-hour market like XAUUSD.
  • Mechanical management. Trailing stops, basket take-profits, time filters and position limits that are tedious to run by hand.
  • Testability. A fixed set of rules can be run over years of history in the Strategy Tester — something you cannot do with discretionary judgment.

Where EAs fail

An EA does exactly what it was written to do, including in conditions its author never imagined. The common failure modes:

FailureWhat it looks like
Regime changeRules tuned for ranging markets keep firing through a strong trend (or the reverse).
OverfittingParameters that were optimised until the backtest looked perfect, and fit noise rather than behaviour.
Unrealistic testingZero spread, no slippage, no swap — results that the live account can never reproduce.
InfrastructureA sleeping laptop, a lost connection or a terminal update stops the EA mid-position.
Unbounded riskStrategies that add to losing positions without a hard account-level limit.
Silent errorsTrading disabled, wrong symbol name, a rejected order — and nobody notices for days.

What it takes to run one

  1. Install it

    Copy the .ex5 into the terminal's MQL5\Experts folder and refresh the Navigator. How to install an EA on MT5 has the exact steps.

  2. Allow it to trade

    Algo trading has to be allowed in three places: the terminal options, the EA's own settings, and the Algo Trading button. How to enable algorithmic trading.

  3. Test it

    Run it in the Strategy Tester with realistic costs, then on a demo account in real time. How to backtest an EA in MT5.

  4. Host it

    Keep the terminal running and connected — usually on a VPS. Do you need a VPS?

  5. Supervise it

    Check its logs (the Experts and Journal tabs), its drawdown and its connection. An unattended EA still needs attention.

How to evaluate an EA

Before an EA trades real money, you should be able to answer these questions from evidence, not from marketing:

  1. What is the strategy? Trend-following, mean reversion, breakout, grid, martingale — each has a characteristic way of losing. If the seller will not say, assume the worst.
  2. What is the worst case? The largest drawdown in testing, and whether anything caps losses at account level. For strategies that add positions, the full exposure at maximum depth.
  3. How was it tested? Which modelling mode, which spread, which period — and does the period include violent markets?
  4. Is there live evidence? A verified live or forward record that includes the bad stretches, not just a screenshot of the good ones.
  5. What does it need to run? Minimum balance, leverage, broker conditions, hosting, and what happens if the connection drops mid-trade.
  6. Can you stop it? Pausing, closing positions and changing risk without editing code.

Common EA strategy families

FamilyWins whenLoses when
Trend-followingMarkets make sustained movesMarkets chop sideways (many small losses)
Mean reversionPrice oscillates around a levelA trend starts and does not come back
BreakoutRanges resolve into strong movesBreakouts fail and reverse
Grid / averagingPrice ranges and retracesPrice runs one way further than the grid can absorb
ScalpingCosts are low and execution fastSpreads widen or slippage rises

Grid strategies are popular for gold because gold often retraces, and dangerous for the same reason: the time it does not retrace is when the losses concentrate. What is grid trading? covers the mechanics.

Go deeper

Each of these takes one part of this guide further.

Sources

Educational content, not financial advice. Trading gold and other leveraged products carries a high level of risk, including the possible loss of some or all of your capital. Automated strategies do not guarantee profit, and past or simulated performance is not indicative of future results. Risk disclosure.