MetaTrader 5 automation

What Is a MetaTrader 5 Expert Advisor? From Signal Logic to Live Orders

Published Horizon Algo

A MetaTrader 5 Expert Advisor, usually called an EA, is a program that runs in the MT5 trading platform. It can analyze incoming data and, when programmed and permitted to do so, send instructions to open, modify or close trades.

The important distinction is between identifying a condition and completing a trade. An EA defines what should happen when its conditions are met. MetaTrader and the broker's trading server then process the resulting requests. A signal is not a fill, and attaching an EA to a chart does not by itself establish that it is ready to trade.

This guide explains that operating chain: the program, its data, its rules, its trade requests and the environment in which it runs.

EA, indicator or script: what is the difference?

MetaTrader 5 supports different types of MQL5 programs. They can share calculations, but they have different roles.

ProgramMain roleWhat the trader should understand
Expert AdvisorOngoing, event-driven analysis and trading logicIt can evaluate conditions and send trade requests when its code and permissions allow. Not every EA is a fully automated trading system.
Custom indicatorCalculate and present analytical informationA plotted line, arrow or alert is not itself an instruction to the broker. An EA can use indicator values in its own decisions.
ScriptRun a task through its start functionIt may perform a trading operation if permitted. Unlike an EA, it does not receive the recurring NewTick events used by tick-driven robots.

A script is commonly used for a one-off task, but its code can contain a longer-running process. The distinction is its program lifecycle, not a promise that every script finishes immediately.

Similarly, an EA does not have to trade. It can be designed for analysis or assistance. What makes a particular EA fully automated is its implementation of the trading decisions and actions described in its documentation, not the file's label alone.

How an EA turns a market update into a trading action

The details differ between programs, but an automated trading workflow can be understood as six connected steps.

  1. Receive an event. The platform calls a handler included in the EA, such as its function for new quotes, timer events or trade transactions.
  2. Read the required data. The EA obtains prices, bar values, indicator calculations and relevant account or position information.
  3. Evaluate its rules. Entry conditions, exit conditions and any programmed filters determine whether an action is allowed.
  4. Prepare a trade request. The program specifies the action, symbol, volume and other fields required for that operation.
  5. Check the response. The server processes the request. The EA must distinguish acceptance, execution and rejection rather than assuming success.
  6. Update and manage state. The program tracks the resulting orders, deals and positions and applies its subsequent rules.

This is a conceptual sequence, not a requirement that every EA uses the same code structure. Some systems separate entry calculations from position management. Others monitor several symbols or timeframes. The product's implementation determines what it actually reads and controls.

Ticks and bars answer different timing questions

A tick is an incoming quote update. A bar groups market data into a defined interval. The fact that an EA is attached to a time-based chart does not mean its entire logic runs only when a candle closes.

In MQL5, OnTick() handles NewTick events for the symbol of the chart to which the EA is attached. An EA can also use other supported events, including timers and trade transactions. It does not have to put every decision inside OnTick().

For a tick-driven EA, two common approaches are:

  • Intrabar evaluation: examine conditions as quote events are processed, while the current bar is still developing.
  • New-bar-gated evaluation: detect a new bar and evaluate the relevant rules once, often using the previous completed bar.

The second approach is implemented in the EA's code. It is not a universal MT5 switch that turns every EA into a bar-close system. In a tick-driven implementation, recognition of the new bar depends on an arriving quote, rather than an independent promise to act at the exact clock boundary.

MQL5 timeseries index zero refers to the current, unfinished bar. Values read from that bar can change before it completes. A condition based on a completed bar therefore differs from one based on the developing bar, even when the indicator period is identical.

There is another important qualification: MT5 processes an EA's events sequentially. If a NewTick event is already queued or being handled, another NewTick event is not added to that queue. “Tick-driven” does not mean that an EA receives a separate callback for every quote regardless of how long its processing takes.

The useful question is not simply “Does it run on ticks or candles?” Ask which rules run on which events, which bar they read and when position management is evaluated.

A signal, an order, a deal and a position are not the same thing

A signal is an internal conclusion from the strategy's rules. It may lead to a request, but another condition can still block the action.

MetaTrader distinguishes the subsequent trading objects:

  • Order: an instruction to the broker to buy or sell. It may be a market order or a pending order.
  • Deal: an execution resulting from an order. One order can result in more than one deal.
  • Position: the resulting market exposure, as recorded under the account's position-accounting system.

An EA may request an immediate trade, place a pending order, change an existing instruction or close a position. The available actions depend on the program and the symbol's trading rules.

Sending a request is not proof of execution. MetaQuotes explicitly states that a successful OrderSend() return does not by itself mean that the requested trade has been executed. The program needs to examine the server response and subsequent trading state. Trade-transaction events can provide updates as processing continues.

This distinction explains why a visible chart condition, an EA message and a filled position should not be treated as interchangeable evidence.

Why the symbol, timeframe and broker matter

The EA receives data and trades within a particular environment. Matching the name of the software is not enough to reproduce that environment.

Symbol and contract specifications

Use the exact broker symbol supported by the EA. Check any prefix or suffix requirements rather than assuming the program will identify an alternative name automatically.

MT5 exposes symbol properties such as contract size, minimum price change, minimum volume, volume step, stop-distance restrictions and permitted filling modes. These properties affect which requests are valid and how a volume or price setting should be interpreted.

Do not assume that the same number of lots, points or price digits has the same meaning on every broker's instrument specification.

Timeframe and data

Use the chart timeframe specified by the product. Some EAs use the current chart's symbol and period. Others explicitly request data for additional symbols or periods. The displayed chart alone does not reveal the complete input set.

The broker's available price history and incoming quotes form part of the operating environment. Changing the source data or timeframe can change the values on which the EA evaluates its rules.

Account structure and execution conditions

MT5 supports both netting and hedging accounts, with the accounting system set by the broker. Netting maintains one combined position per symbol. Hedging allows multiple positions in the same symbol, including opposite positions.

An EA's position-management logic must support the account mode being used. A program designed around separate positions should not be assumed to work unchanged with a combined net position.

Execution settings and trading permissions matter too. The broker's server checks requests against the account and symbol conditions. The same signal does not establish that different accounts will accept or execute the same request in the same way.

Inputs configure the EA, not the whole trading environment

The Inputs tab contains parameters exposed by the developer. An EA may offer many, a few or none.

Depending on the product, inputs may control signal calculations, permitted directions, order volume, trading windows, trade identification or position-management rules. Their names and units are product-specific. A setting described as points should not be silently interpreted as pips, and a percentage should not be interpreted without knowing its calculation base.

MT5 can save and load parameter presets. A preset restores the saved input values. It does not establish that the selected broker account, chart, trading permissions or license activation are correct.

Changing inputs reinitializes the EA. Changes to the chart symbol or period also trigger its deinitialization and reinitialization lifecycle. Follow the product's instructions for making changes when orders or positions already exist.

Time filters deserve particular attention. MQL5's TimeCurrent() reports server-derived quote time, not the computer's local time. That does not prove every EA uses server time: a developer can choose another time source. Confirm the time basis used by the specific EA, including any documented daylight-saving adjustments.

Account, server and trading permissions must agree

Before enabling trading, confirm the actual account number, server and demo or live status. Investor access allows observation and analysis but not trading. Seeing quotes and an EA on a chart is therefore not proof that the login has trading rights.

Automated trading also has more than one permission layer. The platform-wide Algo Trading or AutoTrading control and the EA's individual trading permission both matter. Platform settings can additionally disable automated trading after account, profile, symbol or timeframe changes.

Turning automated trading off does not necessarily stop the program's calculations. MetaQuotes documents that NewTick events continue while automated trading is disabled. The restriction prevents the EA from sending trade requests.

Consequently, turning that control off should not be confused with an instruction to close positions or cancel pending orders. It can also prevent EA-driven exit or modification requests. Understand the product's stop procedure before using the permission control as an operational shortcut.

Licensing is a separate layer from the broker login and MT5's trading permissions. For Horizon Algo products, use the current licensing instructions and the supplied product documentation. Do not assume that successful installation means activation and trading authorization are complete.

Where the EA runs matters

A locally running EA executes in the desktop terminal, not automatically on the broker's server. Its ongoing calculations depend on the computer or VPS and the terminal remaining operational. Data-dependent decisions and trading requests also require the relevant connections.

MetaTrader offers virtual hosting as an alternative operating environment. Using hosting still requires the intended EA and configuration to be deployed and checked there. A hosting subscription alone is not evidence that the correct instance is running.

Separate locally executed logic from instructions already accepted by the trading server. Server-side Stop Loss and Take Profit levels are different from a rule that requires the EA to calculate a condition and send a close request. MT5's built-in Trailing Stop also runs in the platform rather than on the server.

If the terminal stops, ongoing local logic cannot continue there. That does not mean an existing position disappears or that every server-side instruction stops working. Check how the particular EA implements its exits and which instructions actually exist on the account.

What automation handles, and what remains with the trader

An EA can automate the repeated actions included in its code. It cannot supply operating decisions that were never programmed or verify every assumption behind the trader's setup.

The EA can automate, when implementedThe trader still needs to decide or verify
Reading data and evaluating specified conditionsWhether the supported symbol, timeframe and data are selected
Sending entry, modification and exit requestsWhich account receives them and whether trading is authorized
Calculating volume under its sizing rulesWhether the configuration and resulting exposure are appropriate
Applying documented filters and position-management rulesWhat those controls actually do and how they behave when interrupted
Logging programmed events and responsesWhether the platform, connections and intended instance remain operational

Only one EA can run on a given chart. Separate charts can host separate instances, but they can still trade into the same account. Before running multiple instances, establish how the software identifies its own orders and positions and whether the combination is supported.

Monitoring should distinguish an EA waiting for a valid condition from an EA that cannot act. Review its documented status messages and the platform's Experts and Journal records rather than treating inactivity alone as proof of a fault.

Understand the program before evaluating its results

The Strategy Tester provides a separate environment for historical testing. Its settings include the EA, inputs, symbol, period and tick-modeling choices. Those choices are part of what was tested, not background details.

A test report does not establish that the installed EA has the correct account, permissions, activation or live operating environment. Configuration checks and historical-result interpretation answer different questions.

For the report itself, see How to Read an Automated Trading Strategy Backtest. Horizon Algo's research and testing methodology describes the company's published development process.

For supported products and their individual setup requirements, use the MetaTrader 5 Expert Advisor collection. The guide library provides related explanations without replacing the documentation supplied with each EA.

The central idea is straightforward: an EA connects defined logic to permitted trading actions. Understanding that connection means knowing what data it reads, when its rules run, what requests it sends and which parts of the operating chain remain under the trader's control.

Official sources

Primary documentation reviewed on November 17, 2026:

Platform behavior and documentation can change. Product-specific instructions should take precedence over this general explanation.