Last updated: November 18, 2026 · By: Tim Morris
An .mq4 file is the readable source code of an MT4 indicator or Expert Advisor, opened and edited in MetaEditor. An .ex4 file is the compiled program MetaTrader 4 runs. Compiling turns .mq4 into .ex4 in one direction only: you cannot get usable source back from an .ex4. MT5 works the same way with .mq5 and .ex5.
Almost every indicator download comes as one or both of these files, and which one you have decides what you can do with it. For the install steps themselves, see our guide to installing MT4 indicators.
What is an MQ4 file?
An .mq4 file is the source code of an MT4 program, written in the MQL4 language. It is plain text: open it in MetaEditor (press F4 in MT4) and you can read every input, every calculation and the author’s comments.
Because you can read it, you can change it: add an alert, fix a bug or rework a signal, then compile again. MT4 cannot run the .mq4 itself.
You will also meet .mqh files. These are include files, shared code a program pulls in with an #include line. They usually live in MQL4/Include, or next to the .mq4 when the #include line uses quotes. They never run on their own, and an .mq4 that needs a missing one will not compile.
What is an EX4 file?
An .ex4 file is the compiled program MT4 loads onto a chart. MetaQuotes’ own help says the Navigator “shows only executable indicator files (*.EX4)”, so an indicator without one never appears in your list.
It is binary, not text. When we compiled the 87-line EA shown in full below, the 3,155-byte .mq4 became roughly 9 to 10 KB of unreadable .ex4 bytes. The exact size is not fixed: 12 compiles of the same unchanged file gave 11 different sizes, from 9,118 to 10,040 bytes. The MetaEditor documentation describes the format as “hiding the original program algorithm”.
You still see the surface: the Inputs tab lists every setting the author exposed, and you can change them. MetaQuotes also says a grey diamond on a Navigator icon means the program has no source file or could not be compiled, so a working indicator with a grey diamond is either compiled-only or has an .mq4 that no longer compiles.
What is the difference between EX4 and MQ4 files?
| .mq4 | .ex4 | .mq5 | .ex5 | |
|---|---|---|---|---|
| What it is | Source code (text) | Compiled program | Source code (text) | Compiled program |
| Can you read and edit it? | Yes | No | Yes | No |
| Runs on | Nothing until compiled | MT4 only | Nothing until compiled | MT5 only |
| Indicator folder | MQL4/Indicators | MQL4/Indicators | MQL5/Indicators | MQL5/Indicators |
| Opened by | MetaEditor | MT4 terminal | MetaEditor | MT5 terminal |
MetaEditor writes the compiled file into the same folder as its source. Expert Advisors follow the same pairing in MQL4/Experts.
How does an MQ4 file become an EX4?
Compiling is a MetaEditor job:
- In MT4, open File > Open Data Folder and copy the .mq4 into
MQL4/Indicators. - Press F4 to open MetaEditor, then open the file.
- Press F7 to compile. The Errors tab should end with “0 errors, 0 warnings”.
- Back in MT4, right-click the Navigator’s indicator list and choose Refresh.
Will MT4 compile the .mq4 for you? Do not count on it: MetaQuotes documents compiling as a MetaEditor step, and the Navigator lists only .ex4 files. Compiling it yourself also shows you any errors instead of a silent blank.
Errors usually mean a missing .mqh file or code written before MetaQuotes rebuilt MQL4 with build 600 on 3 February 2014.
Why do developers ship EX4 files only?
Developers ship only the .ex4 to protect their work. A compiled file lets the author share or sell an indicator without handing over the logic. A licence lock, such as an account number or expiry date, only means something in a compiled file, because in source code anyone could delete it.
We checked how common this is. In a November 2026 audit of 2,579 indicator download posts on ForexMT4Indicators.com, 59% shipped .mq4/.mq5 source code and 37% were compiled-only (.ex4/.ex5 with no source).
| Platform | Download posts checked | Ship source code | Compiled-only | Neither / not checkable |
|---|---|---|---|---|
| MT4 | 1,811 | 59.0% | 37.2% | 3.8% |
| MT5 | 768 | 59.2% | 37.2% | 3.5% |
| All | 2,579 | 59.1% | 37.2% | 3.7% |
Percentages are rounded, so a row can total 99.9%. The last column covers downloads holding neither file type, or ones we could not check. Roughly three in every eight of our downloads arrive as a file whose code you cannot read, which is why the next two sections matter.
Can you convert an EX4 file back to MQ4?
You cannot turn an .ex4 back into usable .mq4 source, at least not in any way you should use. Since build 600, MetaQuotes says new EX4/EX5 files carry “a serious and completely revised protection”, and its MQL5 Cloud Protector page states that EX4/EX5 files “are reliably protected from decompilation”. Compiling also throws away the author’s comments.
Treat “EX4 to MQ4 converter” sites as a red flag. Decompiling an indicator you did not write, without the author’s permission, usually breaches the licence it came with and can infringe the author’s copyright. The MQL5 Freelance rules list decompilers alongside hacking tools as forbidden.
Our in-house development team led by Tim Morris never decompiles. Ask the author for the source, or use our EX4/EX5 rebuild service: we study what it shows on the chart and write a new, customisable one with full source.
What can you do with a compiled-only indicator?
A compiled-only indicator still leaves you four routes that work without its source code, and none of them break the file open.
1. Use it and change its inputs
Adjust everything on the Inputs tab. Some downloads here also include a .tpl chart template with the settings already applied.
2. Read its buffers from your own EA with iCustom
Most lines and arrows an indicator draws sit in numbered buffers, and an EA can read them with iCustom. The MQL4 iCustom reference only requires the indicator to be compiled (an .ex4) and placed in MQL4/Indicators: no source needed.
To find the buffer numbers, press Ctrl+D to open the Data Window and hover over a bar with an arrow. The indicator’s values are listed in order, which usually maps to buffer 0, 1, 2. MQL4’s iCustom reads buffers 0 to 7, and a bar with no arrow usually returns EMPTY_VALUE (2147483647), though some indicators use 0.
The EA below reads a buy and a sell buffer once per bar at shift 1, the last closed bar, because an arrow on the forming bar 0 can vanish before the close. This is the complete file: it compiled in MetaEditor with 0 errors and 0 warnings on 18 November 2026, and it places no trades.
//+------------------------------------------------------------------+
//| ReadEx4Buffers.mq4 |
//| Reads two buffers of a compiled-only (.ex4) indicator once per |
//| closed bar with iCustom. It places no trades: it prints and |
//| alerts, so you can see what the indicator is really telling you. |
//+------------------------------------------------------------------+
#property copyright "ForexMT4Indicators.com"
#property link "https://forexmt4indicators.com/ex4-vs-mq4/"
#property version "1.00"
#property description "Reads the buy and sell buffers of a compiled indicator on each closed bar."
#property strict
//--- inputs
input string InpIndicatorName = "MyArrows"; // Indicator file in MQL4/Indicators, without .ex4
input int InpBuyBuffer = 0; // Buy arrow buffer (find it in the Data Window)
input int InpSellBuffer = 1; // Sell arrow buffer
input bool InpPopupAlert = true; // Pop-up alert when an arrow prints
datetime g_lastBarTime = 0;
void OnTick()
!ReadBuffer(InpSellBuffer, 1, sell))
g_lastBarTime = 0; // read failed: try again on the next tick
return;
if(buy != EMPTY_VALUE)
Signal("BUY", buy);
if(sell != EMPTY_VALUE)
Signal("SELL", sell);
// Reads one buffer value. Returns false if the indicator could not be read.
// An empty arrow comes back as EMPTY_VALUE (some indicators use 0 instead).
bool ReadBuffer(const int bufferIndex, const int shift, double &value)
ResetLastError();
// No inputs are passed after the name, so the indicator runs with its default settings
value = iCustom(_Symbol, _Period, InpIndicatorName, bufferIndex, shift);
int err = GetLastError();
if(err != 0)
PrintFormat("iCustom(%s, buffer %d) failed, error %d", InpIndicatorName, bufferIndex, err);
return(false);
if(value == 0.0)
value = EMPTY_VALUE; // treat 0 as "no arrow"
return(true);
int OnInit()
// MQL4 iCustom can read buffer indexes 0 to 7 only
if(InpBuyBuffer < 0
bool IsNewBar()
datetime t = Time[0];
if(t == g_lastBarTime)
return(false);
g_lastBarTime = t;
return(true);
void Signal(const string side, const double price)
string msg = StringFormat("%s %s: %s arrow at %s on the closed bar",
_Symbol, EnumToString((ENUM_TIMEFRAMES)_Period), side,
DoubleToString(price, _Digits));
Print(msg);
if(InpPopupAlert)
Alert(msg);
//+------------------------------------------------------------------+
With no inputs after the name, the indicator runs on its defaults; if you changed any, pass all of them in their original order. Then check the Experts tab: each logged price should match an arrow on the chart. An arrow the EA logged that later vanishes means the indicator repaints, as our guide to repainting indicators explains. One it never logged usually means it repaints or back-paints the arrow onto an older bar; first rule out a wrong buffer number or arrows drawn as chart objects.
For the trading half, see our step-by-step guide to creating an Expert Advisor.
Gold note. The EA reads _Symbol, so it works unchanged on XAU/USD whatever your broker calls gold (XAUUSD, GOLD or a suffixed name), and it prints prices with the symbol’s own decimals.
3. Wrap it for alerts
In the EA’s Signal() function, swap Alert(msg) for SendNotification(msg). Once you tick Enable Push notifications and enter your MetaQuotes ID under Tools > Options > Notifications, each signal reaches the MT4 app on your phone. This works only if the indicator keeps its signals in buffers rather than chart objects, and does not repaint.
4. Have a new tool rebuilt from its behaviour
For different logic, or the indicator on MT5, the compiled file is a dead end. Describe what it draws and when, with screenshots, and a new indicator can be written from scratch to behave the same, leaving you with source code you own. Prefer to skip code on the trading side? Our comparison of no-code EA builders covers that route.
EX5 vs MQ5: does MT5 work the same way?
MT5 works the same way. An .mq5 is MQL5 source code and an .ex5 is the compiled program MT5 runs, with the same one-way compile. Our overview of the MetaTrader 5 platform covers its wider feature set.
The files do not cross over. An .ex4 never runs on MT5, and MT5’s iCustom needs a compiled .ex5 (normally in MQL5/Indicators). Moving from .mq4 to .mq5 is a rewrite, not a rename: MQL4’s iCustom returns a value, while MQL5’s returns a handle you read with CopyBuffer.
Still choosing a platform? Start with our MetaTrader 4 platform guide.
Why won’t my EX4 file load?
Check the Experts and Journal tabs of the Terminal window (Ctrl+T) first, because the error line usually names the cause:
- Wrong folder. It belongs in
MQL4/Indicatorsinside the data folder, not the program folder; refresh the Navigator afterwards. On a Mac, read installing MetaTrader 4 on a Mac first. - It needs DLL imports. It will not run until you tick Allow DLL imports on its Common tab, and the DLL usually goes in
MQL4/Libraries. Read the next section first. - Missing companion indicators. A “cannot open file” line naming an .ex4 you do not have means it calls another indicator through iCustom; install that one too.
- Built for a newer terminal. MetaQuotes’ build 970 release notes (June 2016) state that “EX4 programs compiled in build 970 and above will not run in old terminal builds”. Update MT4.
- Wrong platform. An .ex5 never loads in MT4, and an .ex4 never loads in MT5.
Is it safe to allow DLL imports?
Allow DLL imports only for files from authors you trust. Without DLLs, MQL4 code is fenced in (its file functions work only inside the MQL4/Files sandbox and the terminals’ shared Common/Files folder), but a DLL is ordinary Windows code with no such limits. MetaQuotes itself labels the option “potentially dangerous, enable only for trusted applications”.
Never tick it for an .ex4 from a Telegram group or a “free cracked EA” site. Enable it per program on the Common tab, since the Tools > Options setting is only the default for newly attached programs. An arrow indicator that demands DLL access owes you an explanation.
Rather have it built?
Our development team can turn an indicator into an EA, including many compiled .ex4 indicators that expose their signals, or rebuild a compiled indicator you bought as a customisable new one. You get a fixed price before you pay, with the source code included.
Risk disclaimer: Forex and CFD trading carries a high level of risk and may not be suitable for all traders. The strategies and indicators described in this article are educational. Past performance does not guarantee future results. Always test on a demo account before risking real capital.
Frequently asked questions
Do I need both the EX4 and MQ4 files?
No. MT4 runs the .ex4 on its own, so a compiled-only download works normally. The .mq4 is only needed to read or change the code. If you have only the .mq4, open it in MetaEditor and press F7 to create the .ex4.
Which is better, EX4 or MQ4?
Neither runs better: MT4 runs the .ex4, which is compiled from the .mq4. The .mq4 is the more useful file to own, because it lets you read the logic, fix a bug, add an alert or have the tool rewritten for MT5. When a download offers both, keep the .mq4.
How do I install an EX4 file in MT4?
In MT4, choose File > Open Data Folder and copy the .ex4 into MQL4/Indicators, or MQL4/Experts for an Expert Advisor. Back in MT4, right-click the Navigator’s list and choose Refresh, then drag the indicator onto a chart. Our guide to installing MT4 indicators walks through each step.
Can I open an EX4 file in MetaEditor?
No. MetaEditor works with source files (.mq4, .mq5 and .mqh), and an .ex4 holds no readable code. You can still attach it in MT4 and change every setting on its Inputs tab, but changing the logic needs the .mq4 from the author.
How do I convert an MQ4 file to EX4?
Compile it. Open the .mq4 in MetaEditor (press F4 in MT4) and press F7. With 0 errors, the .ex4 appears in the same folder as the source. Refresh the MT4 Navigator and the indicator is ready to attach.
Is there a free EX4 to MQ4 decompiler that works?
Not one you should use. MetaQuotes says EX4/EX5 files are reliably protected from decompilation, with protection rebuilt in build 600 (February 2014), and decompiling someone else’s file usually breaches the licence it came with and can infringe the author’s copyright. Ask the author for the source, or have a new tool built from its behaviour.
Are EX4 files safe?
Without DLL imports, an .ex4 is fenced in: its file functions only reach the MQL4/Files sandbox and the terminals’ shared Common/Files folder. An Expert Advisor can still place trades when AutoTrading is on and live trading is allowed in its settings, so test any new EA on a demo account first. Allow DLL imports only for authors you trust.
Can I use an MT4 EX4 indicator on MT5?
No. MT5 runs .ex5 files, and an .ex4 cannot be converted because there is no source to work from. With the .mq4, a developer can rewrite it in MQL5; without it, the clean option is a new MT5 indicator built to behave the same way.
Why is my indicator icon grey in the MT4 Navigator?
MetaQuotes’ help says a grey diamond on a program icon means the program has no source code file or could not be compiled. If the indicator attaches and draws normally, you usually have the .ex4 without its .mq4; if an .mq4 is in MQL4/Indicators too, it is failing to compile (press F7 on it in MetaEditor to see why).
Do I need the MQ4 file to use an indicator in an EA?
No. MQL4’s iCustom reads the compiled .ex4 directly from MQL4/Indicators. You need the buffer numbers, which the Data Window (Ctrl+D) helps you find, and the indicator must keep its signals in buffers rather than drawing them as chart objects.
Explore forex broker accounts
Visit these broker websites to check the account options, regional availability and terms that apply to you before opening an account.
Trading forex and CFDs carries a significant risk of loss and is not suitable for everyone. Broker links are affiliate links; we may earn a commission if you use them.


