What Is an MT5 Expert Advisor? A Plain-English Guide
- An MT5 Expert Advisor runs directly on your MetaTrader 5 terminal to analyze prices and send orders by fixed rules.
- Indicators only draw lines on a chart and scripts run just once, but an Expert Advisor runs continuously on incoming price ticks.
- The program relies on core MQL5 event functions including OnInit for setup, OnTick for live quote calculations, and OnDeinit for shutdown.
- You must turn on platform-wide algorithmic trading and grant chart permissions before an Expert Advisor can open any position.
- High-risk recovery methods like unhedged martingale or open-ended grid systems blow up trading accounts and must be avoided.
What is an MT5 Expert Advisor?
An MT5 Expert Advisor is a rule-based software program written in the MQL5 language that runs inside the MetaTrader 5 terminal to analyze market quotes, place orders, and manage positions on your broker account without human intervention.
In everyday conversation, traders simply call this software an EA or a trading robot. Instead of sitting in front of your screen waiting for hours for a setup to form on EUR/USD, the program watches incoming quotes for you. It carries out specific rules set by its developer. When conditions align, the program sends trade requests straight to your broker.
Because the program follows explicit mathematical logic, it removes hesitation and revenge trading. To learn how automated rules compare with manual execution, read our breakdown of bot vs manual trading. The software does not guess what the market will do next. It simply handles risk and order execution identically every single time, whether the trade ends as a gain or a loss.
How does an Expert Advisor work inside MetaTrader 5?
An Expert Advisor works as an event-driven program that reacts whenever a new price quote arrives from your broker, checking your trading criteria against live prices and sending automated trade instructions through MetaTrader 5.
Every time the market price updates, MetaTrader 5 triggers an event called a tick. The Expert Advisor reads this incoming data using built-in MQL5 handlers: OnInit loads your settings when attached to a chart, OnTick runs its calculation loop on every single price change, and OnDeinit cleans up memory when the software is removed.
If you attach an EA to an hourly chart for gold, the OnTick function inspects moving averages, price action levels, or spread limits before calling the OrderSend function. Afterward, it monitors open positions, trailing your stop loss or taking profit according to code. For a clear understanding of the trading mechanics behind order sizing and price movements, explore pip and lot size explained.
How does an EA differ from indicators and scripts?
An Expert Advisor can manage trades continuously on every price tick, whereas a custom indicator only displays visual information on a chart and a script runs a single command once before shutting down.
Traders new to MetaTrader 5 often confuse these three tools because they all sit inside the Navigator panel. A custom indicator calculates mathematical values and paints lines or histograms over price candles. It gives you visual feedback, but MetaTrader 5 explicitly blocks indicators from opening, adjusting, or closing trades on your account.
A script has the authority to trade, but it executes only once. For instance, if you want an emergency tool that closes five open EUR/USD positions simultaneously, you drop a script onto the chart. The script sends the close orders and terminates. An EA stays attached to the chart indefinitely, evaluating every tick until you choose to remove it.
| Feature | Expert Advisor (EA) | Custom Indicator | MQL5 Script |
|---|---|---|---|
| Primary Purpose | Automates analysis and executes live trades | Analyzes price and displays visual chart patterns | Carries out a single one-off manual command |
| Order Execution | Opens, modifies, and closes positions automatically | Cannot place or modify orders | Can send orders, but only once on command |
| Runtime Lifecycle | Runs continuously on every incoming price tick | Calculates continuously across chart history | Executes once and terminates immediately |
| Typical Use Case | Running rule-based strategies on EUR/USD or gold | Plotting moving averages, RSI, or support zones | Closing all open positions at the same moment |
What files make up an MT5 Expert Advisor?
An MT5 Expert Advisor consists of an MQ5 source code file that a programmer can read and edit, and an EX5 compiled file that the MetaTrader 5 platform reads and executes on a live chart.
When a developer builds a robot in the MetaEditor program, they write the logic in an MQ5 file. This file contains the plain text code, including entry indicators, position sizing formulas, and risk limits. However, the MetaTrader 5 terminal cannot run human-readable text directly.
The developer compiles the MQ5 file into an EX5 executable file. This binary format protects the developer's source code and allows MetaTrader 5 to run calculations at high speed. When you purchase or download a commercial EA, you usually receive an EX5 file that you drop straight into the platform folder.
Why do traders use automated Expert Advisors?
Traders use automated Expert Advisors to execute disciplined trading strategies around the clock, eliminate emotional mistakes like panic closing, and react instantly to fast-moving market setups.
Human traders struggle with discipline when money is on the line. After a streak of losses, many people hesitate and skip the next valid signal. After a sudden market spike, they might jump in impulsively out of fear of missing out. An EA executes predefined rules without emotional bias, keeping trading behavior consistent.
Automation also frees you from being chained to a computer desk. For instance, Gixodia builds algorithmic software for MetaTrader 5 that trades by predefined rules, the same way every time, free of hesitation and fatigue. As an account equity threshold gets close, it scales down and pauses, maintaining strict consistency across market sessions. You can review the complete walkthrough on our setup page to see how simple terminal setup really is.
What are the infrastructure requirements to run an EA safely?
To run safely, an EA requires an active MetaTrader 5 terminal, an uninterrupted internet connection, and proper account trading permissions provided by your broker.
Because MetaTrader 5 executes an EA locally, the terminal must remain open and connected to broker servers for the software to manage trades. If your laptop goes to sleep, loses battery power, or drops Wi-Fi, the EA stops receiving ticks. It cannot adjust trailing stops or exit trades until the platform reconnects.
Most serious traders use a Virtual Private Server, which is a remote computer running in a secure data center that stays online day and night. Alternatively, some modern setups avoid this headache completely. For example, the bundle plan runs hosted, requiring nothing to install and no computer left running at home. Managing connection quality is also vital for keeping costs low; see understanding spread commission slippage for details on trade execution friction.
How to do it, step by step
- Step 1: Open the MT5 data folder. Launch your MetaTrader 5 terminal, click File in the top navigation bar, and select Open Data Folder.
- Step 2: Copy the file to the Experts directory. Open the MQL5 folder, enter the Experts folder, and paste your EA file (ending in .ex5 or .mq5) inside.
- Step 3: Refresh the Navigator window. Return to MetaTrader 5, press Ctrl and N together to display the Navigator window, right-click Expert Advisors, and choose Refresh.
- Step 4: Attach the EA to your chart. Open the chart for the specific instrument and timeframe you want to trade, such as EUR/USD on the 15-minute timeframe, and drag the EA from the Navigator onto the chart.
- Step 5: Adjust your input parameters. In the pop-up settings window, click the Inputs tab to configure your lot size, stop loss, and risk settings according to your plan.
- Step 6: Enable trading permissions. Click the Common tab inside the EA properties window, check the box labeled Allow Algo Trading, and click OK.
- Step 7: Activate platform algorithmic trading. Click the Algo Trading button located on the top toolbar of MetaTrader 5 so that the icon turns green, and confirm a green play symbol appears at the top right of your chart.
Checklist before you take the trade
- Check 1: Confirm your broker account is logged in using the master password rather than a read-only investor password.
- Check 2: Verify that the main Algo Trading button on the top toolbar shows a green active status.
- Check 3: Ensure the Allow Algo Trading checkbox is marked under the Common tab of the EA settings.
- Check 4: Double-check that the EA is attached to the exact instrument and chart timeframe specified by its strategy.
- Check 5: Inspect the top right corner of the chart to verify a green play icon is displayed next to the EA name.
- Check 6: Check the Experts tab in the bottom terminal window to confirm there are no initial loading errors.
Common mistakes and how to fix them
✗ The mistake: The EA displays a red stop sign in the chart corner and fails to place any trades.
✓ The fix: Click the Algo Trading button on the top toolbar to turn it green, press F7 on your chart to open EA properties, and ensure Allow Algo Trading is checked under the Common tab.
✗ The mistake: Logging into the account with an investor password that prevents order placement.
✓ The fix: Log out and log back in using your master trading password, which grants permission to execute and modify orders on the account.
✗ The mistake: Leaving the terminal on a home laptop that enters sleep mode or loses internet connectivity.
✓ The fix: Disable system sleep mode entirely, or move the MetaTrader 5 terminal to a dedicated Virtual Private Server that runs continuously without dropping connection.
✗ The mistake: Using dangerous recovery methods like doubling position size after losses or stacking limitless open orders.
✓ The fix: Never use martingale or unhedged grid strategies because they inevitably blow trading accounts. Always enforce hard stop loss orders and define clear maximum daily loss boundaries.
Frequently asked questions
Can an MT5 Expert Advisor trade when my computer is turned off?
No, an Expert Advisor runs locally inside the MetaTrader 5 software. If your computer shuts down or disconnects from the internet, the EA stops receiving price ticks and cannot execute trades unless hosted on a Virtual Private Server.
What is the difference between an MQ5 file and an EX5 file?
An MQ5 file contains the editable source code written by a developer in the MQL5 programming language. An EX5 file is the compiled, executable application that MetaTrader 5 runs directly on your chart.
Can an Expert Advisor withdraw money from my broker account?
No, an Expert Advisor only has permission to analyze market prices and transmit trade execution orders. It has no technical capability to transfer funds or withdraw money from your broker account.
Why is my MT5 Expert Advisor not placing any trades?
The most common causes are that the Algo Trading button on the top toolbar is turned off, the Allow Algo Trading box is unchecked in the EA properties, or you logged in using a read-only investor password.
Want your trading to follow fixed rules, the same way every time? Gixodia's trading software for MetaTrader 5 trades by predefined rules on your own broker account, in your own name. Try it free for 10 days, a demo account is fine. Trading involves risk and you can lose money.
Sources
- Expert Advisors and Custom Indicators - Algorithmic Trading, Trading Robots - MetaTrader 5 Help (metatrader5.com)
- How to Create an Expert Advisor or an Indicator - Algorithmic Trading, Trading Robots - MetaTrader 5 Help (metatrader5.com)
- Exploring MT5 Expert Advisors: Automate Your Forex Strategy Like a Pro - Phillip Nova - Bringing global market (phillipnova.com.sg)
- What Is an Expert Advisor? Explained for MetaTrader (ea-programmierung.de)