MetaTrader 4 Pro
Download the .mq4 source, compile it in MetaEditor 4 and attach it to a chart, and what differs from the MetaTrader 5 export.
This feature is part of Pro.
MetaTrader 4 exports MQL4 source (.mq4). It can export all 119 parts, the same set as MetaTrader 5, as long as the strategy uses one symbol. Getting the source is part of Pro.
Download and compile
-
In the Builder toolbar, choose MT4 (MQL4).

MT4 (MQL4) selected in the Builder toolbar. -
Click Download .mq4. The file is saved as
EA_Builder.mq4. -
In MetaTrader 4, press F4 to open MetaEditor 4 and open the file. To start from the data folder, choose File > Open Data Folder in MetaTrader 4 and put the file in
MQL4/Experts. -
Press F7 to compile it into an
.ex4. -
Back in MetaTrader 4, refresh the Navigator panel. The EA appears under Expert Advisors.
Nothing is compiled on this site.
Attach it to a chart
- Open a chart of the symbol and timeframe named on the
Checked under:line at the top of the file. - Drag the EA from the Navigator onto the chart.
- Turn on AutoTrading in the toolbar and allow live trading in the EA’s dialog.
- Try it on a demo account first.
Differences from MetaTrader 5
| Topic | MetaTrader 4 |
|---|---|
| Symbols | One symbol per strategy. A strategy that uses a second symbol, or sets a symbol on a part, is not exported. |
| Order fill | MetaTrader 4 has no fill-mode setting. The broker’s policy applies. |
| Tester spread | The MetaTrader 4 tester can use a fixed spread. The MetaTrader 5 tester uses the history. |
| Deciding inside a bar | Supported, as on MetaTrader 5. |
| Wiring | An indicator wired straight into an action, and the other wiring cases on Blocks that can’t be exported. MetaTrader 5 exports them with a warning. MetaTrader 4 refuses them. |
Everything else the code does is the same as the MetaTrader 5 export: the inputs, MagicNumber, OncePerBar and the one-input-per-setting naming.
Check it in the Strategy Tester
- Open the Strategy Tester (View > Strategy Tester, or Ctrl+R).
- Select the EA, the symbol and period from
Checked under:, and the model. The comparison runs behind Match check used Open prices only and Control points. - Run it and compare with the Miner result.
The numbers differ from the Miner for two main reasons.
- Swap. The profit column of the MetaTrader 4 report includes swap. The code does not model it.
- Two exits in one bar. When a bar reaches both the stop loss and the take profit, the order is unknown to the Miner. This matters most for very narrow stops.
Results are an approximation of past data. They do not predict future results.
If the compile fails
- Check that you are in MetaEditor 4. A
.mq5file does not compile there. - Read the first message on the Errors tab.
- If the export was refused, no file was saved. See Blocks that can’t be exported.
Next steps
- Read Match check for what has been compared on MetaTrader 4.
- Compare with the Export overview.
- Go back to the Docs home.