If you have spent any time researching automated trading, you have almost certainly come across the term Expert Advisor, usually abbreviated to EA. At its simplest, an Expert Advisor is a program that runs inside the MetaTrader platform and executes trading logic on your behalf, without you needing to click buy or sell manually. Understanding exactly what an EA is, how it interacts with your broker, and where its limits lie is the foundation of any serious journey into algorithmic trading.

MetaTrader, developed by MetaQuotes, exists in two main versions: MetaTrader 4 (MT4) and MetaTrader 5 (MT5). Both support Expert Advisors written in the platform's own scripting language, MQL4 or MQL5 respectively. When you attach an EA to a chart, it monitors price data in real time, applies its coded rules, and can open, modify, or close positions automatically. The platform itself handles the communication with your broker's server, so the EA does not need to be connected to any external system to place trades.

This article explains the mechanics behind Expert Advisors, covers the practical steps involved in running one responsibly, and highlights the risks you need to understand before going live. Nothing here is personalised advice; the goal is purely to give you the technical and conceptual grounding to make informed decisions.

How an Expert Advisor Actually Works

An EA is built around three core functions that run at different moments in the platform's lifecycle.

  • OnInit: runs once when the EA loads, used to set up variables and check that inputs are valid.
  • OnTick (MT4) or OnBar (MT5): runs every time new price data arrives, which is where the main trading logic sits.
  • OnDeinit: runs when the EA is removed from the chart, used for clean-up tasks.

Inside the main function, the EA evaluates conditions. A simple trend-following EA might check whether a fast moving average has crossed above a slow moving average. If the condition is true, it calls the platform's order functions to open a buy position, attaches a stop-loss and a take-profit, and waits for the next tick to re-evaluate. None of this requires you to be at your computer, which is why traders often run MetaTrader on a Virtual Private Server (VPS) to keep the EA online around the clock.

The role of the MetaTrader terminal

The terminal acts as the bridge between your EA and your broker. It handles authentication, translates order requests into the broker's API calls, and returns execution confirmations. This means the EA itself is never directly exposed to your live account credentials beyond what the terminal manages. It also means that if your internet connection drops, the EA stops working until the connection is restored, which is one reason a VPS is strongly recommended for any serious live deployment.

Inputs and parameters

Every EA exposes a set of user-configurable inputs: lot size, stop-loss distance, indicator periods, trading hours, and so on. These are set in the EA's properties window before it goes live. Choosing appropriate values requires understanding what each parameter controls, because an incorrect setting can cause the EA to trade at a size that exceeds your risk tolerance or to ignore market conditions you intended it to respect.

Backtesting: the Starting Point for Any EA

Before placing real money at risk, the standard practice is to run the EA through MetaTrader's built-in Strategy Tester using historical price data. This process, called backtesting, shows how the EA's rules would have performed on past market data. It is an essential diagnostic step, but it comes with important caveats.

Backtesting results are historical and past performance is not indicative of future results. Markets change, liquidity conditions shift, and a strategy that performed well on data from a specific period may behave very differently in live conditions. Common traps include overfitting, where a developer adjusts parameters until the EA looks excellent on historical data but fails to generalise to new data, and look-ahead bias, where the EA inadvertently uses information that would not have been available at the time of a historical trade.

A more robust evaluation method is forward testing on a demo account, running the EA in real time with simulated funds for at least several weeks before considering a live deployment. This exposes the EA to genuine market conditions, including weekends, news spikes, and spread widening, none of which are perfectly reproduced in a backtest.

For a broader look at how automated systems are constructed and evaluated, the article on how automated forex trading robots work provides a useful technical overview.

Key Risks Specific to Expert Advisors

Running an EA removes emotional decision-making from the process, which is genuinely useful. However, it introduces a different category of risks that manual traders rarely face.

  • Coding errors: a bug in the EA's logic can cause it to open far too many positions, ignore stop-losses, or trade in the wrong direction. Always review the code or have it reviewed by a qualified developer.
  • Over-optimisation: also called curve-fitting, this produces an EA that looks impressive in a backtest but lacks real predictive ability. Evaluate on out-of-sample data to reduce this risk.
  • Connectivity failure: if the terminal disconnects from the broker's server during an open trade, pending orders may not execute as expected. A VPS with a guaranteed uptime guarantee from a reputable provider reduces but does not eliminate this risk.
  • Broker dependency: execution quality, spreads, and slippage vary between brokers and can significantly affect an EA's actual trading results compared with backtested figures.
  • Market regime changes: an EA calibrated for a trending market can suffer repeated losses in a ranging market. Monitoring the EA's live performance and having clear criteria for pausing it are essential parts of risk management.

The article on automated trading mistakes beginners make covers many of these pitfalls in detail and is worth reading before you deploy any EA on a live account.

Position Sizing and Risk Management Inside an EA

How an EA sizes each trade is one of the most consequential design decisions. Most EAs offer a choice between a fixed lot size and a dynamic lot size calculated as a percentage of account equity. The percentage-of-equity approach, sometimes called fixed fractional position sizing, is generally considered more robust because it scales exposure down automatically during a losing streak and up during growth.

A typical conservative setting is to risk between 1% and 2% of account equity per trade. At 1% risk per trade, you would need 50 consecutive losing trades to lose half your account, which gives you meaningful information about the system's behaviour before a catastrophic drawdown occurs. These are illustrative figures for educational purposes; appropriate risk per trade depends on the strategy's characteristics and your own financial situation.

If you are interested in how position sizing interacts with long-term account growth, the guide on compound interest in automated trading explains the mechanics clearly, including the asymmetric effect that drawdowns have on compounding.

Curious what algorithmic trading looks like in live conditions? Take a look at the 3 QuantStone algorithms and their track record, verifiable in real time. A 20% commission on profits only.

Trading involves risk and you can lose some or all of your invested capital. Past performance is not indicative of future results. QuantStone is not available to residents of the United States.

Choosing Between MT4 and MT5

MT4 remains the most widely supported platform among retail brokers, and the majority of commercially available EAs are written in MQL4. MT5 is the newer platform and offers several technical advantages: a built-in economic calendar, more order types, improved multi-threading in the Strategy Tester, and support for a wider range of instruments including stocks and futures. However, MQL4 and MQL5 are not directly compatible, so an MT4 EA cannot run on MT5 without conversion.

If you are selecting a broker primarily to run EAs, confirm which platform version they support, whether they allow automated trading (some brokers restrict it in their terms), and what their policy is on Expert Advisors that use high-frequency or scalping strategies. Most brokers that cater to algorithmic traders will publish this information in their trading conditions documentation.

Pre-Made EAs Versus Building Your Own

You do not need to be a programmer to use an Expert Advisor. MetaQuotes operates a marketplace called the MetaTrader Market where developers sell or give away EAs. There are also independent coding forums and communities where EAs are shared. The challenge is evaluating quality. A polished promotional page is not evidence of a sound strategy, and many EAs in public marketplaces have been optimised heavily on historical data without rigorous out-of-sample validation.

If you are considering a pre-made EA, request transparent trading results from a verified account, note the date range covered, check whether those results include slippage and realistic spreads, and remember that past performance is not indicative of future results. Treat any vendor who uses language like 'guaranteed returns' or 'risk-free' as an immediate red flag, since no credible provider in any regulated jurisdiction would make such a claim.

For those who want algorithmic exposure without building or vetting an EA themselves, it is worth understanding what a done-for-you forex trading service involves, so you can weigh that option against self-managed EA deployment. Separately, if you are trying to understand how different algorithmic strategies differ in their approach to the market, the comparison of algorithm strategies covering different risk profiles is a practical reference.

Getting Started: a Practical Checklist

  1. Install MetaTrader 4 or 5 from a broker that explicitly permits automated trading.
  2. Open a demo account and run your chosen EA on it for a minimum of four to eight weeks, covering different market conditions.
  3. Review the EA's inputs carefully and set lot sizes appropriate to your demo balance so the simulation reflects realistic live conditions.
  4. Study the backtest report: examine the maximum drawdown, profit factor, and the ratio of winning to losing trades, not just the headline equity curve.
  5. Set up a VPS if you plan to run the EA continuously, and test that the EA reconnects correctly after a simulated disconnection.
  6. Define in advance the conditions under which you will pause or stop the EA on a live account, for example a drawdown threshold or a sustained period of underperformance.
  7. Keep a trading journal that records why you chose this EA, what you observed during demo testing, and how live performance compares month by month.

Risk warning

Trading involves risk and you can lose some or all of your invested capital. Past performance is not indicative of future results. Only trade with money you can afford to lose. QuantStone does not provide investment advice and nothing here is a recommendation to buy or sell any financial instrument.