The short answer

An Expert Advisor (EA) is a compiled program that lives inside your MetaTrader terminal and trades your rules for you. It watches every price tick, checks your conditions, and sends orders to your broker — no clicking, no 3 a.m. chart checks. In October 2026, MetaTrader 4 builds 1490 and 1491 shipped a bug that stopped some EAs from loading at all, and MetaQuotes had to rush out build 1492 to fix it. That is the whole story of EAs in one incident: the automation is only as reliable as the platform it runs inside, and the terminal can look perfectly fine while the strategy underneath has quietly stopped working.

What an Expert Advisor actually is

An EA is not a cloud service and not a separate app. It is a compiled file — .ex4 on MT4, .ex5 on MT5 — written in MetaQuotes' own language (MQL4 or MQL5) and attached to a chart inside the terminal. While that terminal is open and connected, the EA is alive. Close the laptop, lose the connection, or let the terminal crash, and the EA stops with it. That is why anyone running an EA seriously puts the terminal on a VPS that never sleeps.

The EA does three things, in a loop: read market data, apply your rules, send trade requests. It cannot do anything you did not program into it, and it cannot improvise. If your rule says "buy when the fast average crosses above the slow one," it will buy on every cross — including the tenth whipsaw cross in a sideways market. The discipline is in the rules, not in the program.

The event loop: where the logic lives

MetaTrader runs EAs on events, and each event has its own handler function:

  • OnInit runs once, when the EA loads. Validate your inputs here — bad parameters should fail loudly at load time, not silently at 2 a.m.
  • OnTick fires on every price update. This is where your core trade logic lives, and it is also where most EAs go wrong.
  • OnTimer fires on a fixed interval, useful for checks that should not depend on price movement.
  • OnDeinit runs when the EA is removed or the terminal closes. Use it for cleanup.

The single most important discipline in OnTick is the new-bar guard. OnTick fires on every tick, but a signal computed mid-bar can appear and disappear before the bar closes — the EA equivalent of repainting. A careful EA checks whether a new bar has opened and does nothing on any other tick. Everything in the example below hangs on that one guard.

MT4 vs MT5: the differences that matter

MT4 and MT5 look similar on the surface. Underneath, an EA written for one does not run on the other.

MT4 runs MQL4 EAs, defaults to hedging (multiple positions per symbol), and is the platform most retail forex traders still use. MetaQuotes no longer sells new MT4 licenses and reserves new features for MT5 — but it still ships MT4 builds, and build 1490 (October 2, 2026) changed how stop loss and take profit behave under FIFO rules: when several positions are open on the same symbol, new stop and target levels now apply to all of them. If your EA manages stops per position, that change touches your logic directly.

MT5 runs MQL5 EAs, defaults to netting (one position per symbol), covers more asset classes, and has the stronger tester: it is multi-currency, multi-threaded, and can replay real ticks your broker recorded, spread changes included. Its build 6230 (September 24, 2026) extended the built-in AI Assistant so it can retrieve an EA's input parameters and prepare Strategy Tester runs. The tester is covered in depth in how to backtest a strategy in MetaTrader 5's Strategy Tester — read that before you trust any EA result.

A complete EA you can read

This is a full working skeleton: a long-only SMA crossover that trades once per new bar, risks 1% of equity per trade, and always attaches a stop and a target. It is the same logic as the demo run below.

// SMA-crossover EA — long-only, new bar only, 1% risk per trade
#include <Trade\Trade.mqh>
CTrade trade;

input int    FastPeriod = 10;
input int    SlowPeriod = 30;
input double RiskPct    = 1.0;  // % of equity risked per trade
input double StopATR    = 2.0;  // stop distance, in ATR multiples
input double TargetR    = 2.0;  // target, as a multiple of risk

datetime lastBarTime = 0;

int OnInit() { return(INIT_SUCCEEDED); }

void OnTick()
{
   // Trade once per new bar — intrabar ticks would repaint signals.
   datetime barTime = iTime(_Symbol, PERIOD_CURRENT, 0);
   if(barTime == lastBarTime) return;
   lastBarTime = barTime;

   double fast[], slow[], atr[];
   CopyBuffer(iMA(_Symbol, PERIOD_CURRENT, FastPeriod, 0, MODE_SMA, PRICE_CLOSE), 0, 0, 3, fast);
   CopyBuffer(iMA(_Symbol, PERIOD_CURRENT, SlowPeriod, 0, MODE_SMA, PRICE_CLOSE), 0, 0, 3, slow);
   CopyBuffer(iATR(_Symbol, PERIOD_CURRENT, 14), 0, 0, 2, atr);

   bool crossUp = fast[1] <= slow[1] && fast[0] > slow[0];
   if(!crossUp || PositionSelect(_Symbol)) return;

   double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   double stopDist  = StopATR * atr[0];
   double riskMoney = AccountInfoDouble(ACCOUNT_EQUITY) * RiskPct / 100.0;
   double tickValue = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);
   double tickSize  = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
   double lossPerLot = (stopDist / tickSize) * tickValue;
   double volume = riskMoney / lossPerLot;

   trade.Buy(volume, _Symbol, ask, ask - stopDist, ask + TargetR * stopDist, "SMA cross");
}

Note what the code does not do: it never trades without a stop, it never sizes by gut feel, and it never acts twice on the same bar. Those three omissions are most of what separates an EA that survives from one that blows up.

What the demo run shows

The identical logic was executed in Python on 500 synthetic bars (seed 42) to check the mechanics end to end: 17 crossover signals, 8 closed trades, 5 winners, final equity $108,810.92 from $100,000, maximum drawdown 1.50%. That is a logic check on made-up data, not a return to expect — a 500-bar random walk proves the code runs and the risk math works, nothing more. Any EA vendor quoting backtest profits without showing the test conditions is selling the demo, not the strategy. The same sizing logic, the same stop discipline, and the same new-bar rule are what automating a trading strategy end to end builds into a full five-stage loop.

Where EAs actually break

Most EA failures are not strategy failures. They are infrastructure failures, and October 2026 gave a clean example. Builds 1490 and 1491 carried a defect in loading EX4 files: indicators appeared in the Navigator but never drew on the chart, timer callbacks never fired, and at least one EA entered a continuous error loop after upgrading. MetaQuotes acknowledged the bug on October 5, and broker FXTF confirmed on October 7 that build 1492 resolves it. No verified monetary losses were documented — but an EA that never receives its expected event simply does nothing, and "does nothing" leaves no error message to investigate.

The rest of the failure list is permanent: overfitting to the tester (its fastest modes generate ticks from minute bars, so spread spikes at news mostly do not exist in the test — use "every tick based on real ticks" for final checks), a VPS that reboots mid-trade, a broker whose spreads widen at rollover, and an EA with no kill switch. The fix for each is boring and specific: test on real ticks, run a demo account on the same broker first, log every decision, and set a drawdown limit that halts the strategy automatically.

What to do before it touches real money

  1. Run it in the Strategy Tester on real ticks, then walk it forward on data it has never seen.
  2. Run it on a demo account with the same broker, spread and leverage as your live account.
  3. Read the logs for a week. An EA that trades without logging is un-auditable.
  4. Start live small, with a kill switch: a drawdown limit that stops the EA before you have to.
  5. Keep the terminal on a VPS, and check the build number after every MetaTrader update — October 2026 proved an update can break the automation silently.

If the strategy is yours but the engineering is not, that is exactly what the desk is for: an embedded engineer who builds the EA, grades it against out-of-sample data, and wires in the monitoring and kill switch — the same desk behind the MetaTrader guide for systematic traders. And if you would rather have an engineering team build and run the system for your business, BlackShore Agency works on retainer, with a senior engineer who owns the build. Either way, the rule is the same: the EA is code, the platform is someone else's, and the risk controls are yours to set before the first live tick.