Educational content. This article defines the Expert Advisor and explains how automated trading works in MetaTrader 5, using figures from the Vanto feed. It does not constitute investment advice or a recommendation of any EA. CFD trading carries significant risk of loss and may not be suitable for all investors.
An Expert Advisor (EA) is a program that runs inside the MetaTrader 5 terminal and trades by rule: it reads market data on a chart, applies its code and sends, changes or closes orders automatically. It is written in the MQL5 language and stays active only while the terminal is running. An EA follows its rules exactly, including the bad ones.
This article explains what an EA is, how it differs from an indicator and a script, how it runs, the limits that shape it, and the failure modes that matter for risk. The figures are arithmetic and feed data, not forecasts.
What Is an Expert Advisor in MetaTrader 5?
An Expert Advisor is an automated trading program attached to a single chart in MetaTrader 5, written in MQL5 and compiled into a file with the extension .ex5. The name comes from MetaTrader: an EA is "an expert" in the sense that it applies a fixed procedure, not that it has judgment.
An EA reacts to events. The terminal calls its code when a new price tick arrives, when a timer fires, when a trade is executed or when a chart event occurs. In each call the program can read the account, check open positions and send a trade request to the server. The platform, the symbols and the account modes are described in hedging vs netting in MT5.
Two points define the concept:
- It acts, it does not only display. An indicator draws a line; an EA can trade on it.
- It is bound to a chart and a symbol. One EA instance runs on one chart. To trade five symbols with the same logic, the trader attaches it five times, or uses an EA written to handle several symbols.
Expert Advisor vs Indicator vs Script: What Is the Difference?
An EA trades repeatedly on its own, a script runs once and stops, and an indicator calculates and draws but cannot place orders. All three are MQL5 programs, and they are often confused because they sit in the same navigator panel.
| Program type | What it does | Runs | Can send orders |
|---|---|---|---|
| Expert Advisor | Reads data, applies rules, manages positions | Continuously, on every event, until removed | Yes |
| Script | Executes one task, such as closing all positions | Once, then ends | Yes |
| Indicator | Calculates values and draws them on the chart | Continuously, as prices update | No |
This difference matters in practice. A script that closes all trades is a one-time action. An EA that closes all trades and then opens new ones is a strategy. A moving-average indicator shows a number; an EA that buys when it crosses is a rule with consequences.
How Does an EA Work Step by Step?
An EA follows a loop: it receives an event, reads the state of the market and the account, tests its conditions, and sends a trade request if a condition is true. Nothing in the loop is discretionary.
A simple EA, written out in plain steps:
- A new tick arrives for EURUSD.
- The EA reads the price and, for example, the last two closes of a moving average.
- It checks whether it already has a position, using the position list, not memory.
- If its entry condition is true and there is no position, it calculates the lot size.
- It sends a market order with a stop-loss and a take-profit attached.
- The server answers: executed, rejected, or executed at a different price. The EA must handle each answer.
Step 6 is where many programs fail. The price sent and the price executed can differ, which is the slippage every market order carries. An EA that does not check the answer may believe a position is open when the request was rejected.
What Does an EA Need to Run?
An EA runs only while four conditions hold at the same time: the terminal is open, it is connected to the server, automated trading is switched on in the terminal, and the EA itself is allowed to trade in its settings. Missing any one stops the EA from trading.
| Requirement | What happens if it is missing |
|---|---|
| Terminal open on a computer | The EA stops when the terminal closes or the computer sleeps |
| Connection to the trade server | The EA cannot read prices or send orders; open positions stay on the server |
| AutoTrading button on the toolbar enabled (MetaTrader 5 help wording) | EAs load but are not allowed to trade |
| Trading permission ticked in the EA's own properties | That single EA does not trade, even though others do |
Positions opened by an EA belong to the account, not to the program. When the EA stops, the positions remain open and their stop-loss and take-profit levels stay at the server. The broker can also disable automated trading for an account on the trade server (MQL5 documentation, trade permission). What stops when the EA stops is any management the EA did itself, such as a trail that the code moved. This is the same dependence on the terminal described for trailing stops.
Traders who need the strategy to run all day often host the terminal on a virtual private server, so that the EA continues when the home computer is off. Vanto describes this on its Forex VPS page. It solves the uptime problem only; it does not change what the EA does.
What Limits Does an EA Face? Lot Size and Symbol Rules
An EA has to follow the same order rules as a human: the minimum volume, the volume step and the maximum volume of each symbol, and the contract size that turns lots into exposure. An order outside these limits is rejected, and the code must check them for every symbol it trades.
The table below comes from the Vanto feed. Notional per minimum order is the minimum volume multiplied by the contract size.
| Symbol | Contract size | Min volume | Volume step | Max volume | Notional at minimum |
|---|---|---|---|---|---|
| EURUSD | 100,000 EUR | 0.01 | 0.01 | 200 | 1,000 EUR |
| USDJPY | 100,000 USD | 0.01 | 0.01 | 200 | 1,000 USD |
| XAUUSD | 100 oz | 0.01 | 0.01 | 20 | 1 oz |
| UKOIL | 100 bbl | 0.1 | 0.1 | 100 | 10 bbl |
| US30 | 1 | 0.01 | 0.01 | 100 | 0.01 index units |
| BTCUSD | 1 BTC | 0.01 | 0.01 | 5 | 0.01 BTC |
Source: Vanto feed snapshot, 10 October 2026. Contract size and volume limits can change; check the current specification.
Two consequences follow. First, an EA written with a hard-coded lot step of 0.01 would send invalid sizes on UKOIL, where the step is 0.1. Second, the same lot number means different exposure on each symbol, which is why a "0.1 lot" setting copied from a forex EA to gold changes the risk. The contract size and its effect are covered in what is contract size in trading, and the minimum order in what is minimum lot size in trading.
How Does an EA Size Its Trades? A Worked Example
Most EAs use one of two sizing methods: a fixed lot, or a lot calculated from the amount the trader is willing to lose on the trade. The second method needs the stop distance and the value of one pip.
On EURUSD, one pip on 1 lot is worth USD 10 (100,000 x 0.0001). Take an account of USD 5,000, a risk of 1% per trade and a stop-loss of 25 pips:
- Amount at risk: 5,000 x 0.01 = USD 50
- Risk per lot: 25 pips x USD 10 = USD 250
- Lot size: 50 / 250 = 0.20 lot
With a fixed lot of 0.20, the same 25-pip stop always risks USD 50 while the account is USD 5,000, but it risks 1.5% after the account falls to USD 3,333 and 0.7% after it rises to USD 7,143. The calculated method keeps the percentage constant by changing the lot; the fixed method keeps the lot constant and lets the percentage drift. The relationship between the stop and the reward is in what is the risk-reward ratio.
If the calculated lot is not a multiple of the volume step, the EA must round down to the step, otherwise the order is rejected. Rounding changes the risk slightly, which a backtest on a larger step may not show.
What Do Backtests Show, and What Do They Miss?
A backtest runs an EA on stored price history in the MT5 Strategy Tester and reports what it would have done, so it tests the logic against the past but does not prove anything about the future. The result depends on the quality of the data and on the costs the test assumes.
The usual gaps between a test and live trading:
- Spread. A test uses a modelled spread. Live spread widens around news and at rollover, as described in what is the spread in trading.
- Slippage and rejections. The tester can emulate an execution delay (MetaTrader 5 help, Strategy Tester), but live orders fill against real liquidity and may fill at another price or not at all.
- Swap. An EA that holds positions overnight pays or receives swap, with a triple charge on one day of the week, and the swap in a test may not match the account's current rates; see what is swap in trading.
- Overfitting. An EA tuned until it fits one period of history can look excellent there and fail on new data, because it learned the noise of that period.
A test is a stress test of the code, and it is useful for finding bugs. As evidence of future profit it is weak, and a trader who treats it as proof takes more risk than the report suggests.
When Does an EA Fail? Common Mistakes
An EA fails in predictable ways, and most of them come from the rules, not from the technology. The first four below are the ones that cause the largest losses.
1. Doubling after losses. Rules that increase the lot after each loss (martingale) rely on a win arriving before the account runs out. Starting at 0.01 lot and doubling after each loss, the lot at the tenth trade is 0.01 x 2^9 = 5.12 lots, and the ten trades together use 0.01 x (2^10 - 1) = 10.23 lots. If each loses 20 pips on EURUSD, the cumulative loss is 10.23 x 20 x USD 10 = USD 2,046, from a first trade that risked USD 2. The sequence also raises used margin at each step, which brings the stop-out closer; the levels are in what is stop-out level in trading and the margin mechanics in what is margin in trading.
2. Averaging down without a limit. An EA that keeps adding to a losing position has no stop. The same warning applies to the grid and scale EAs covered in scale trading.
3. No stop-loss in the code. A program that closes trades only on its own signal depends on the terminal and the connection to do it. A stop-loss placed on the server survives a disconnect.
4. Assuming one position per symbol. Accounts in hedging mode can hold several positions on one symbol, and code written for netting can open an opposite position when it meant to close one. The details are in hedging vs netting in MT5.
5. Running unattended through news. Around major releases the spread widens and slippage rises. An EA does not know a release is coming unless it was written to check a calendar.
6. Leverage ignored. Leverage amplifies losses as well as gains, and an EA that sizes lots without reading free margin can open more exposure than the account carries. Per asset class the maximum leverage differs: 1:500 on forex and metals, 1:100 on indices and energies, 1:10 on crypto. The margin call is at 100% and the stop-out at 50%.
Where Do EAs Come From?
EAs come from three sources: the trader writes the code, buys or downloads a ready-made program, or orders one from a developer. Each source has a different risk, and the platform does not vet the strategy in any of them.
| Source | What you get | Main risk |
|---|---|---|
| Write it yourself in MetaEditor | Full control of the rules and the source code | Bugs, and the time to learn MQL5 |
| Marketplace or download | A compiled .ex5 file, sometimes without source code | The vendor's results are not independently verified |
| Freelance developer | Custom code to a specification | Quality varies; the specification must cover error handling |
A compiled file without source code cannot be inspected. A trader running it cannot see whether it uses a stop-loss, doubles after losses or ignores the account mode. Reading the description of the rules, and testing on a demo account first, is the minimum.
Vanto does not supply EAs. On MT5 the platform allows them, and hedging is allowed on the account; the strategy, its source and its risk belong to the trader. Whether a strategy is suitable for a given account is a decision for the trader, and an EA that has not been tested in live conditions with small size is untested.
Calculate the Numbers Before You Automate
Before running an EA, work out what one trade and one losing sequence cost at the lot size it will use. The Vanto trading calculator gives the pip value, margin and notional for each symbol in the feed, so that the lot setting in the EA can be checked against the amount the trader is willing to lose.
Frequently Asked Questions
Is an Expert Advisor the same as a trading robot or bot?
Yes, in everyday use. "Robot", "bot" and "EA" all mean an automated program that trades by rule. "Expert Advisor" is the MetaTrader term, and it refers specifically to a program attached to a chart in MT4 or MT5.
Does an EA make money by itself?
No. An EA executes the rules it was given, and the result depends on those rules, costs and market conditions. It can lose as fast as it can gain, and a strategy that worked in a backtest can fail live.
Can an EA trade when my computer is off?
Only if the terminal is running somewhere else, for example on a virtual private server. Stop-loss and take-profit levels already placed on open positions stay on the server, but any logic the EA performs itself stops when the terminal closes.
What language are Expert Advisors written in?
MetaTrader 5 EAs are written in MQL5, a C++-like language, in the MetaEditor included with the platform. The compiled program is an .ex5 file. MetaTrader 4 uses the older MQL4 language, and its programs are not interchangeable with MT5.
Do EAs work on hedging accounts?
Yes, but the code must be written for the account mode. In hedging mode a symbol can hold several positions, so an EA that selects a position only by symbol name can manage the wrong one. A robust EA reads the account mode at start-up.
Is it safe to use an EA on a live account at once?
It is safer to start on a demo account and then run a small lot size live. A demo run shows how the EA behaves with real spread, slippage and rejections, which a backtest does not reproduce, although a demo fill is still not identical to a live one.
Risk warning. Trading securities, futures, options, and contracts for differences are complex financial instruments that require knowledge and understanding. Prices can fluctuate significantly and securities may become valueless. Investors may incur losses exceeding the potential for profits. Trading on margin can result in losses greater than the amount initially deposited. Past performance is not necessarily a guide to future performance. The information in this article is for educational purposes only and does not constitute investment advice, a recommendation, or an offer to buy or sell any financial instrument. Consider whether CFD trading is appropriate for your circumstances and seek independent advice if necessary.