You have an Expert Advisor — a .mq5 source file you generated, bought or wrote — and you want it running on a MetaTrader 5 chart. The whole process takes about five minutes once you know where things live. This guide follows the Windows desktop version of MT5; the steps in the macOS version are very similar.
.mq5 vs .ex5
- .mq5 is the source code. You can read and edit it in MetaEditor.
- .ex5 is the compiled program that MetaTrader actually runs.
MetaEditor compiles a .mq5 into an .ex5 for you. If you only have an .ex5, you can skip the compile step, but you can't inspect or change the logic.
Step 1: Put the file in the Experts folder
- In MetaTrader 5, open File → Open Data Folder.
- Go to MQL5 → Experts.
- Copy your
.mq5file here. Sub-folders are fine if you like to stay organised.
Every MT5 installation — including each broker's own copy of MT5 — has its own data folder, so always use Open Data Folder rather than browsing Program Files.
Step 2: Compile it in MetaEditor
- Press F4 (or click the IDE button in the toolbar) to open MetaEditor.
- In MetaEditor's Navigator, open Experts and double-click your file.
- Press F7 or click Compile.
- Check the Errors tab in the Toolbox at the bottom. "0 errors" means an
.ex5was created next to your source file. Warnings don't stop compilation, but they're worth reading.
If you see errors, each message includes a line number. Common causes are a missing #include, a typo, or code written for MQL4 rather than MQL5 — the two languages are not compatible.
Step 3: Allow algorithmic trading
Back in MetaTrader 5:
- Go to Tools → Options → Expert Advisors and tick Allow algorithmic trading. Read the other options on that tab, such as disabling algo trading when the account or profile changes; leave them on unless you have a reason not to.
- Make sure the Algo Trading button in the main toolbar is switched on. It's the master switch: when it's off, no EA can trade.
Step 4: Attach the EA to a chart
- Open the Navigator (Ctrl+N) and expand Expert Advisors. If your EA is missing, right-click and choose Refresh.
- Open a chart of the symbol and timeframe the EA was designed for.
- Drag the EA onto the chart, or double-click it.
- In the Common tab of the dialog, check that algo trading is allowed for this EA.
- In the Inputs tab, set the parameters — risk, stop distances, magic number, trading hours. Double-click a value to edit it.
- Click OK.
The EA's name appears in the top-right corner of the chart with a small icon. If the icon shows that trading is disabled, re-check the Algo Trading button and the Common tab.
Step 5: Watch the logs
Open the Toolbox (Ctrl+T):
- The Experts tab shows the EA's own messages — anything it prints, plus load and unload events.
- The Journal tab shows terminal events, including rejected orders and connection problems.
On the first day, check these tabs regularly. Silence isn't always good news: an EA that never trades may be blocked by a filter or a setting.
Step 6: Test before trading live
Run the EA in the Strategy Tester first (Ctrl+R, or View → Strategy Tester):
- Choose the EA, symbol, timeframe and date range.
- For modelling, pick Every tick based on real ticks where available — it's the most realistic option.
- Set a realistic deposit and leverage, then start the test.
Then run it on a demo account for a few weeks before going live. Backtests miss things that live markets don't — see backtesting mistakes that inflate results.
Common problems and fixes
| Problem | Likely cause | Fix |
|---|---|---|
| EA not in the Navigator | Wrong folder, or not compiled | Use Open Data Folder → MQL5 → Experts, compile, then Refresh |
| EA attached but never trades | Algo Trading off, or a filter blocks entries | Check the toolbar button, the Common tab and the Experts log |
| Autotrading disabled by client terminal (10027) | Algo Trading is switched off | Turn on the Algo Trading button |
| Invalid stops (10016) | Stop too close to the price | Widen the stop beyond the broker's minimum distance |
| Invalid volume (10014) | Lot size not allowed for this symbol | Use the symbol's minimum lot and volume step |
| Market closed (10018) | Outside the symbol's trading hours | Check the sessions in the symbol's specification |
Keeping it running
An EA only works while MetaTrader is open and connected. If your computer sleeps, the terminal closes or the internet drops, the EA stops managing trades — and open positions stay open. Traders who run EAs around the clock usually use a VPS, a remote server that stays on. Whatever you choose, make sure every trade carries a server-side stop-loss, so a disconnection never leaves a position unprotected.
Before going live, run through our MQL5 Expert Advisor risk checklist, and size trades with the position size calculator.
Try it with Edgoro
Describe your strategy and Edgoro generates a complete MQL5 Expert Advisor with risk inputs, a magic number and clear comments. Download the .mq5 file, follow the steps above, and if MetaEditor reports an error, paste the message into the chat so Edgoro can fix it. Generate your first EA free.
Automated trading carries substantial risk. Always test on a demo account first; nothing here is investment advice.