Open MQ4 File in MetaEditor and Read Its Inputs
EABuild Team · · 12 min read

On this page
- What to have ready before you open an MQ4 file in MT4
- Where MetaTrader 4 expects an MQ4 file to be
- Steps to open an MQ4 file in MetaEditor
- Reading the header of an MQ4 file
- How to find the inputs of an MQ4 file
- Compile the MQ4 file in MetaEditor
- Three MQ4 source packages and what each one gives you to read
- Checks after you compile an MQ4 file and common problems
- FAQ
- Reading an MQ4 file on a demo account this week
To open MQ4 file source code you need MetaEditor, the code editor that ships with MetaTrader 4, and the file placed in the right folder of the terminal's data folder. An MQ4 file is plain text written in MQL4, the language of MT4 programs. This post walks through where to put the file, how to open it, how to find the settings the program exposes, and how to compile it so the platform can run it. It stops at reading and compiling; it does not teach you to change trading logic.
What to have ready before you open an MQ4 file in MT4
Opening a source file is quick, but a few preparations save you from confusing errors later.
- MetaTrader 4 with MetaEditor. MetaEditor is installed together with the terminal. If you do not have the platform yet, the download page is at metatrader4.com.
- The file unpacked. Source code usually arrives in a ZIP archive. Extract it first and keep the folder layout, because a project can contain more than one file.
- A file written for MT4. An .mq4 file is MetaTrader 4 code. It will not compile as an MT5 program without being rewritten. If you are unsure which format you hold, the MQ4 and MQ5 source code guide explains the difference.
- A spare copy. Copy the untouched download into another folder. Whatever happens later, you can return to the starting point.
Source file and compiled file are different things
The .mq4 file is the text you read. The .ex4 file is the compiled result that MetaTrader 4 actually runs. Some source downloads include both, and some include only the source. When there is no .ex4, you build it yourself in the steps below.
Where MetaTrader 4 expects an MQ4 file to be
MetaEditor shows only the files that sit inside the terminal's data folder, so the file has to be there before you can browse to it. In MetaTrader 4 choose File, then Open Data Folder. Inside it you will find a folder named MQL4, and below that the folders that matter here.
- Experts holds expert advisors (EAs, programs that place trades automatically).
- Indicators holds indicators.
- Scripts holds scripts that run once.
- Include holds shared header files with the .mqh ending, which main files pull in.
An EA source file goes into MQL4\Experts. If the download has sub-folders, copy them across as they are. Each terminal installation has its own data folder, so if you run several MT4 terminals, open the data folder from the terminal you plan to use.
Steps to open an MQ4 file in MetaEditor
Follow these steps in order.
- Copy the .mq4 file into the correct folder of the data folder, for example MQL4\Experts for an EA.
- In MetaTrader 4 press F4, or click the MetaEditor button on the toolbar. MetaEditor opens in its own window.
- In the Navigator panel on the left, expand the MQL4 folder and then Experts. If the file is not listed, right-click the folder and refresh the view.
- Double-click the .mq4 file. The text opens in the editor window.
- Scroll to the top. Look at the comment lines and the lines that start with #property before you read anything else.
You can also open a file from MetaEditor's File menu, but files outside the data folder are awkward to compile and to find from the terminal later. Keeping everything inside the data folder avoids that.
If the file opens as unreadable text
A readable MQ4 file shows words, brackets and semicolons. If you see strange symbols instead, you have probably opened an .ex4 file or a corrupted copy. An .ex4 cannot be read as source. You need the .mq4 version of the program.
Reading the header of an MQ4 file
The first lines of an MQ4 file often tell you more than the rest of the program. Comments start with two slashes, or sit between a slash-star and a star-slash. They are notes for people, and the compiler ignores them. The #property lines are different: they are instructions to the platform, for example a version number, a copyright line, a link or a description. Some of them make the terminal show the inputs window when you attach the program.
Do not take a comment as proof of what the code does. A comment says what the author meant when they wrote it, and code can change while a comment stays the same. Treat comments as a guide to where to look.
How to find the inputs of an MQ4 file
Inputs are the settings you see in the EA's properties window when you attach it to a chart. In MQL4 they are declared near the top of the file, outside any function, with the word extern or, in newer code, input. Each line gives a type, a name, a default value and often a comment.
- The type tells you what kind of value it takes: a whole number (int), a number with decimals (double), true or false (bool), or text (string).
- The name is what the code calls the value. It often hints at the purpose, such as a lot size or a stop distance.
- The default is the value used until you change it in the inputs window.
- The trailing comment on the same line is usually the label shown next to the setting. It is the quickest explanation of a parameter.
Use the search function (Ctrl+F) for extern and input to jump through every setting. Read the whole list once before attaching the program to a chart, so the inputs window holds no surprises. If a package ships without set files (saved lists of input settings you load from the inputs window), the defaults written in the source are the only starting values you have.
Settings that deserve a second look
Pay attention to any input that controls position size, the number of open orders, or a distance between orders. In a strategy with grid or martingale logic, those values shape how exposure grows when price moves against the first trade. A grid strategy opens extra orders at set price steps, and martingale means increasing the lot size after a losing trade. Reading the inputs does not tell you how the program will behave, but it tells you which switches exist.
Compile the MQ4 file in MetaEditor
Compiling turns the .mq4 text into an .ex4 file. The compiler also checks the grammar of the code, so it is a useful first test that the download is complete.
- With the .mq4 file open, press F7 or click Compile on the toolbar.
- Open the Errors tab in the panel at the bottom of MetaEditor.
- Check the totals line. It should report zero errors. Read any warnings as well.
- Look in the folder of the source file. A new .ex4 file with the same name is the compiled program.
- Switch back to MetaTrader 4 and refresh the Navigator panel, or restart the terminal. The program appears in the Expert Advisors list.
If you only want to run a ready-made file and not build one, the post on installing an EA or indicator in MT4 is the shorter route. A parallel guide for the newer platform is how to compile MQ5 in MetaEditor.
Reading what the Errors tab says
Each row names a file, a line and a column. Double-click a row and the cursor jumps there. Errors stop the build and no .ex4 appears. Warnings let the build finish but point at code worth checking. When there are many errors, start with the first one: a single missing bracket early in the file can cause a long list below it. Fix it, press F7 again, and see what is left. For the meaning of a message or a function, the MQL documentation is the place to look it up.
Three MQ4 source packages and what each one gives you to read
Real packages make the steps concrete. The shop lists several MT4 source code downloads, and their fact sheets differ in what you get, so the first thing to do after unzipping is to check which files are inside.
The HFT Gold EA Source Code (MQ4) package is for MetaTrader 4 and is listed for XAUUSD and BTCUSD on M1, with a scalping strategy. As listed, it holds one compiled file and one source file, no set files and no DLL. Because a compiled file is included, you can compare it with a build you make yourself.
The Waka Waka EA Source Code (MQ4) download is a single MQ4 source package with no compiled file. The listing names grid, news trading and neural network / AI as its strategy and marks grid/martingale as yes, for AUDCAD, AUDNZD and NZDCAD on M15. With no .ex4 included, the compile step above is not optional: you must build the file before it can run.
The Euro Scalper EA Source Code (MQ4) package is also a single source file without a compiled copy. The listing describes a scalping and grid strategy on EURUSD, M1, with grid/martingale marked as yes. Its inputs are whatever the source declares, since no set files come with it.
In all three cases the listings give no description of the entry logic, so the code is the only place to learn it. Open the file, read the header, list the inputs, and compile. That is all this post asks of you.
Checks after you compile an MQ4 file and common problems
A program that compiles has passed a grammar check, not a trading check. Before you use a build, go through these points.
- Confirm zero errors and read every warning.
- Attach the program to a chart of the symbol and timeframe it was written for, with algo trading enabled, and watch the Experts tab of the terminal for messages.
- Open the inputs window and compare it with the list you made from the source.
- Run it on a demo account first, long enough to see how it handles changing spreads.
- Check the settings against your broker's account type before any live use.
The file does not appear in the Navigator
Check that it sits in the data folder of the terminal you are using, in the right sub-folder, and that you refreshed the Navigator. A file copied to another terminal's data folder will not show up.
Compile says it cannot open an include file
The main file refers to a .mqh header that is missing or in the wrong place. Look at the #include lines at the top. A name in angle brackets is searched in the Include folder, while a name in quotation marks is searched next to the source file.
The build works but the terminal behaves as before
You may have compiled a copy in a different folder from the one the terminal reads. Remove the program from the chart and attach it again after the build.
Errors in code written for MT5
If a file uses MQL5 functions, it was not written for MT4 and MetaEditor will report unknown functions or wrong parameters. Rewriting it is a development task, not a quick fix.
FAQ
Where must an MQ4 file be saved for MetaEditor to show it in the Navigator?
An MQ4 file must sit inside the MetaTrader 4 data folder, which you open with File, then Open Data Folder. An EA source file goes into MQL4\Experts, and sub-folders from the download are copied across as they are. Each terminal installation has its own data folder, so with several MT4 terminals open the data folder of the one you plan to use, then refresh the Navigator.
Why does an MQ4 file open as unreadable symbols in MetaEditor?
An MQ4 file opens as unreadable symbols when the file is really an .ex4 compiled program or a corrupted copy. A readable MQ4 file shows words, brackets and semicolons, and an .ex4 cannot be read as source. You need the .mq4 version of the program to read it or to build your own .ex4.
How do I find the input settings in an MQ4 file?
The input settings of an MQ4 file are declared near the top, outside any function, with the word extern or, in newer code, input. Each line gives a type, a name, a default value and often a comment that is shown as the label. Press Ctrl+F and search for extern and input to jump through every setting before you attach the program to a chart.
What do the #property lines at the top of an MQ4 file do?
The #property lines at the top of an MQ4 file are instructions to the platform, such as a version number, a copyright line, a link or a description. Some of them make the terminal show the inputs window when you attach the program. Comments are different: the compiler ignores them, and a comment shows what the author meant, not proof of what the code does.
Reading an MQ4 file on a demo account this week
A sensible first exercise is to take one MQ4 file, open it, write down its inputs in a note, compile it and attach it to a demo chart without changing anything. Once you can do that, you can read other projects the same way. You can browse the source code downloads in the catalogue, and every product is also included in the membership. eabuild.app sells digital downloads; it is not the developer or publisher of these programs, and this post makes no promise that any file you edit will work as you intend.
Trading foreign exchange and CFDs carries a high level of risk and may not be suitable for all investors. Past performance does not guarantee future results; only trade with money you can afford to lose.
Tags: EA Source Code, MQL4, MetaEditor


