You downloaded an Expert Advisor as source code, a file ending in .mq5, and now you need to turn it into something MetaTrader 5 can actually run. That runnable file is the .ex5, and you build it by compiling the source in MetaEditor. This guide walks through the whole process from a clean install.
What you need first
- MetaTrader 5 installed on your computer. MetaEditor comes bundled with it, you do not install it separately.
- The EA source file, for example
MyRobot.mq5. - Any include files (
.mqh) the EA depends on, if it uses custom libraries.
Step 1: Open MetaEditor
Launch MetaTrader 5, then press F4 or click the MetaEditor icon in the toolbar. You can also open MetaEditor directly from the Start menu. MetaEditor is the development environment where all compiling happens.
Step 2: Put the file in the right folder
Expert Advisors live in a specific folder. In MetaTrader 5 click File, Open Data Folder, then go into MQL5Experts. Copy your .mq5 file there. If the EA came with include files, copy those into MQL5Include or leave them next to the .mq5 if the code references them with quotes like #include "myfile.mqh".
Step 3: Open and compile
Back in MetaEditor, open your .mq5 from the Navigator panel on the left. Then press F7 or click the Compile button. MetaEditor reads the code and builds the .ex5.
Watch the Toolbox panel at the bottom. If you see 0 errors, 0 warnings, the compile worked and a fresh .ex5 now sits next to your source in the Experts folder. Warnings are usually fine to ignore. Errors mean the code will not build until they are fixed.
Step 4: Load the EA in MetaTrader 5
Return to MetaTrader 5. In the Navigator, right click Expert Advisors and choose Refresh. Your EA appears in the list. Drag it onto a chart, allow algorithmic trading, and it is ready.
Common compile errors and what they mean
- cannot open source file: an include file is missing. Put the missing
.mqhinMQL5Includeor next to the EA. - undeclared identifier: the code calls something that is not defined, often because a required include was not added.
- wrong parameters count: usually a version mismatch, the source was written for a different build of MQL5.
If an EA will not compile no matter what, the source may be incomplete or written for MQL4 instead of MQL5. Check our guide on MQL4 vs MQL5 to tell them apart.
Practice with real source code
The best way to get comfortable with MetaEditor is to compile real robots. Every EA in our free source code library ships with the full .mq5 so you can open it, compile it, and study how it works. Grab one, follow the steps above, and you will have a working .ex5 in a couple of minutes.
