Guides
Install an Expert Advisor in MetaTrader 5
Save the .mq5 file from your Edgoro answer in MetaTrader 5's MQL5/Experts folder (File > Open Data Folder), open it in MetaEditor and press F7 to compile it, refresh the Navigator, then drag the Expert Advisor onto a chart of the symbol it was written for. Allow Algo Trading in the EA's Common tab and switch on the Algo Trading button in the toolbar. Test it in the Strategy Tester and on a demo account first: a clean compile in MetaEditor shows that the file builds, not how it trades.
On this page
Before you start
- MetaTrader 5 on a computer or a VPS. Expert Advisors run in the desktop terminal; the MetaTrader mobile apps can't run them. This guide follows the Windows version, and the macOS version is similar.
- MetaTrader 5, not MetaTrader 4. Edgoro writes MQL5 only, and MQL5 code doesn't run in MetaTrader 4.
- A demo account at your broker, to test before any live account.
- The .mq5 file: the Download button under the code, or Copy and paste into a new Expert Advisor file in MetaEditor.
Steps
- In MetaTrader 5, open File > Open Data Folder. Each installation (each broker's copy of MT5) has its own data folder, so use this menu rather than browsing Program Files.
- Open MQL5 > Experts and copy the .mq5 file there.
- Open MetaEditor (F4, or the IDE button in the toolbar), find the file under Experts in its Navigator and press F7 (Compile). The Errors tab at the bottom should end with 0 errors; MetaEditor then writes the .ex5 next to the .mq5. Warnings don't stop the build.
- Back in MetaTrader 5, open the Navigator (Ctrl+N). If the EA isn't listed under Expert Advisors, right-click and choose Refresh.
- Open a chart of the symbol and timeframe the EA was written for, and drag the EA onto it (or double-click it).
- In the dialog, open the Common tab and allow Algo Trading for this EA. Older builds call the feature AutoTrading, so the wording may differ.
- In the Inputs tab, check the risk per trade, stop-loss, take-profit, magic number, trading hours and maximum spread, then click OK.
- Switch on the Algo Trading button in the main toolbar. It's the master switch: when it's off, no EA can trade. Tools > Options > Expert Advisors must also allow algorithmic trading.
- Check the icon next to the EA's name in the top-right corner of the chart, and the Experts tab of the Toolbox (Ctrl+T), where the EA prints its messages.
Test it in the Strategy Tester first
- Open View > Strategy Tester (Ctrl+R).
- Choose the EA, the symbol, the timeframe and a date range.
- For modelling, pick Every tick based on real ticks where your broker provides it, set a realistic deposit and leverage, and start.
- Then attach the EA to a demo account and watch it for a while before any live account.
The Strategy Tester modelling modes explain what each mode simulates, and the MQL5 EA risk checklist lists what to check before going live.
Broker details that change behaviour
- Symbol names. Brokers often add a suffix, such as
EURUSD.morEURUSDm. An EA usually trades the symbol of the chart it's attached to, so open the chart from your broker's Market Watch. If an input or the code names a symbol, it must match that exact name. - Minimum lot and volume step. Each symbol has a minimum volume, a maximum and a step: right-click it in Market Watch and choose Specification. A size outside them is rejected with 10014 Invalid volume.
- Stop level. Some symbols need a minimum distance between the price and a stop; a stop too close returns 10016 Invalid stops.
- Market hours. The Specification also lists the trading sessions. Orders outside them, at weekends or on holidays return 10018 Market closed.
- Filling mode. Brokers accept different order filling modes; a mismatch returns 10030 Unsupported filling mode.
If it doesn't work
| Symptom | Likely cause | Fix |
|---|---|---|
| The EA isn't in the Navigator | Wrong folder, or not compiled | File > Open Data Folder > MQL5 > Experts, compile with F7, then Refresh |
| MetaEditor shows errors | A file edited by hand, or a build difference | Paste the error lines into the same Edgoro conversation: the corrected file is compiled in MetaEditor again. The MQL5 error library explains each message. |
| The EA is attached but never trades | Algo Trading off, or a filter (hours, spread, trades per day) blocks entries | Check the toolbar button, the Common tab and the Experts tab. See 10027 Autotrading disabled and 4752 Trading by EAs prohibited. |
| Orders rejected for money | Margin too low for the size | 10019 Not enough money: lower the risk or the lot |
| An indicator handle fails at start | Wrong symbol, timeframe or parameters | 4802 Indicator cannot be created |
| The EA stops when the computer sleeps | The EA runs only while the terminal is open and connected | Keep the computer on, or run MetaTrader 5 on a VPS, with a stop-loss on every trade |
The MQL5 examples are complete programs that compile as they are, useful to practise these steps on a demo account.
Related pages
- Install an Expert Advisor on MT5 (full guide)
- MQL5 error library
- MQL5 examples
- Strategy Tester modelling modes
- MQL5 magic number explained
- MT5 Expert Advisors and the compile check
- Position size calculator
Trading involves substantial risk of loss and is not suitable for every investor. Edgoro is a software tool, not a broker or financial adviser: nothing it produces is investment advice, and past or backtested performance does not guarantee future results.
Something wrong or missing? Email contact@edgoro.com