Where an EA sits among MQL5 programs
The MQL5 reference describes four main kinds of programs for MetaTrader 5:
| Program | What it does | How it runs |
|---|---|---|
| Expert Advisor (EA) | an automated trading system | attached to a chart until removed; one EA per chart |
| Indicator | calculates and draws a technical indicator | attached to a chart; several can share one chart |
| Script | performs an action once | removes itself from the chart when done |
| Service | auxiliary tasks | needs no chart |
How an EA works
An EA responds to terminal events. The main one is OnTick, fired by a new tick on the chart's symbol. There are others: OnTimer (on a timer), OnTrade and OnTradeTransaction (orders, positions or history changed). An EA tags its orders with its own magic number to tell them apart from other EAs' and manual ones. It can trade only when algo trading is allowed — both in the terminal and in the EA's own properties. It runs only while the terminal is open, so for round-the-clock work it is kept on a VPS.
By job, EAs fall into three groups:
- Trading — open and close trades by their own rules.
- Managing — handle open positions: moving stops, partial closes, risk limits.
- Informational — do not trade but pass data on: alerts, statistics, account monitoring.
Common mistakes
- Judging an EA by the strategy tester: a live account has different spread, execution and slippage — see «MT5 tester vs live account».
- Not checking for a grid or martingale: a smooth curve until the first strong move, then a large part of the account gone (the risks of grids and martingale).
- Running two EAs with the same magic number on one symbol.
- Keeping a trading EA on a home computer that goes to sleep.
EAs in Davinchu
A MetaTrader account connects to Davinchu through the Davinchu Trade Monitor EA — for MT5 and MT4, at any forex and CFD broker on MetaTrader 4 and 5, prop firms included. It sends trades, balance, equity and account history to the dashboard; it needs no algo trading, because the monitor only reads data. Trades from your own trading EAs are split by magic number.
The T-Manager risk manager for MT5 is a separate EA with a trading panel: it takes its limits from the dashboard and, once the daily loss or drawdown reaches a limit, closes new entries through its panel. It does need algo trading. How to install an EA and allow it WebRequest — «How to install an EA in MT5»; how to check someone else's EA before buying — «How to check an EA or a signal before buying».
Frequently asked questions
How is an EA different from an indicator or a script?
An EA is a trading system that keeps running on a chart and responds to ticks and trade events. An indicator calculates and draws values; a script performs an action once and removes itself from the chart.
Does an EA keep working if I turn off my computer?
No: the EA runs inside the terminal. For round-the-clock work the terminal with the EA is kept on a VPS.
Can I run two EAs on one chart?
No, one chart takes one EA, and a new one replaces the old. Run the second EA on another chart — even one of the same symbol.