Final up to date: November 18, 2026 · By: Tim Morris
An .mq4 file is the readable supply code of an MT4 indicator or Professional Advisor, opened and edited in MetaEditor. An .ex4 file is the compiled program MetaTrader 4 runs. Compiling turns .mq4 into .ex4 in a single course solely: you can’t get usable supply again from an .ex4. MT5 works the identical means with .mq5 and .ex5.
Nearly each indicator obtain comes as one or each of those information, and which one you have got decides what you are able to do with it. For the set up steps themselves, see our information to putting in MT4 indicators.
What’s an MQ4 file?
An .mq4 file is the supply code of an MT4 program, written within the MQL4 language. It’s plain textual content: open it in MetaEditor (press F4 in MT4) and you’ll learn each enter, each calculation and the creator’s feedback.
As a result of you may learn it, you may change it: add an alert, repair a bug or rework a sign, then compile once more. MT4 can’t run the .mq4 itself.
Additionally, you will meet .mqh information. These are embrace information, shared code a program pulls in with an #embrace line. They normally reside in MQL4/Embody, or subsequent to the .mq4 when the #embrace line makes use of quotes. They by no means run on their very own, and an .mq4 that wants a lacking one is not going to compile.
What’s an EX4 file?
An .ex4 file is the compiled program MT4 hundreds onto a chart. MetaQuotes’ personal assist says the Navigator “exhibits solely executable indicator information (*.EX4)”, so an indicator with out one by no means seems in your record.
It’s binary, not textual content. After we compiled the 87-line EA proven in full beneath, the three,155-byte .mq4 grew to become roughly 9 to 10 KB of unreadable .ex4 bytes. The precise measurement isn’t fastened: 12 compiles of the identical unchanged file gave 11 totally different sizes, from 9,118 to 10,040 bytes. The MetaEditor documentation describes the format as “hiding the unique program algorithm”.
You continue to see the floor: the Inputs tab lists each setting the creator uncovered, and you’ll change them. MetaQuotes additionally says a gray diamond on a Navigator icon means this system has no supply file or couldn’t be compiled, so a working indicator with a gray diamond is both compiled-only or has an .mq4 that now not compiles.
What’s the distinction between EX4 and MQ4 information?
| .mq4 | .ex4 | .mq5 | .ex5 | |
|---|---|---|---|---|
| What it’s | Supply code (textual content) | Compiled program | Supply code (textual content) | Compiled program |
| Are you able to learn and edit it? | Sure | No | Sure | No |
| Runs on | Nothing till compiled | MT4 solely | Nothing till compiled | MT5 solely |
| 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 identical folder as its supply. Professional Advisors comply with the identical pairing in MQL4/Consultants.
How does an MQ4 file develop into an EX4?
Compiling is a MetaEditor job:
- In MT4, open File > Open Knowledge Folder and replica the .mq4 into
MQL4/Indicators. - Press F4 to open MetaEditor, then open the file.
- Press F7 to compile. The Errors tab ought to finish with “0 errors, 0 warnings”.
- Again in MT4, right-click the Navigator’s indicator record and select Refresh.
Will MT4 compile the .mq4 for you? Don’t depend on it: MetaQuotes paperwork compiling as a MetaEditor step, and the Navigator lists solely .ex4 information. Compiling it your self additionally exhibits you any errors as a substitute of a silent clean.
Errors normally imply a lacking .mqh file or code written earlier than MetaQuotes rebuilt MQL4 with construct 600 on 3 February 2014.
Why do builders ship EX4 information solely?
Builders ship solely the .ex4 to guard their work. A compiled file lets the creator share or promote an indicator with out handing over the logic. A licence lock, akin to an account quantity or expiry date, solely means one thing in a compiled file, as a result of in supply code anybody might delete it.
We checked how widespread that is. In a November 2026 audit of two,579 indicator obtain posts on ForexMT4Indicators.com, 59% shipped .mq4/.mq5 supply code and 37% have been compiled-only (.ex4/.ex5 with no supply).
| Platform | Obtain posts checked | Ship supply 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 whole 99.9%. The final column covers downloads holding neither file kind, or ones we couldn’t test. Roughly three in each eight of our downloads arrive as a file whose code you can’t learn, which is why the following two sections matter.
Can you exchange an EX4 file again to MQ4?
You can’t flip an .ex4 again into usable .mq4 supply, no less than not in any means you must use. Since construct 600, MetaQuotes says new EX4/EX5 information carry “a severe and utterly revised safety”, and its MQL5 Cloud Protector web page states that EX4/EX5 information “are reliably protected against decompilation”. Compiling additionally throws away the creator’s feedback.
Deal with “EX4 to MQ4 converter” websites as a crimson flag. Decompiling an indicator you didn’t write, with out the creator’s permission, normally breaches the licence it got here with and might infringe the creator’s copyright. The MQL5 Freelance guidelines record decompilers alongside hacking instruments as forbidden.
Our in-house growth group led by Tim Morris by no means decompiles. Ask the creator for the supply, or use our EX4/EX5 rebuild service: we research what it exhibits on the chart and write a brand new, customisable one with full supply.
What are you able to do with a compiled-only indicator?
A compiled-only indicator nonetheless leaves you 4 routes that work with out its supply code, and none of them break the file open.
1. Use it and alter its inputs
Regulate every little thing on the Inputs tab. Some downloads right here additionally embrace a .tpl chart template with the settings already utilized.
2. Learn its buffers from your individual EA with iCustom
Most strains and arrows an indicator attracts sit in numbered buffers, and an EA can learn them with iCustom. The MQL4 iCustom reference solely requires the indicator to be compiled (an .ex4) and positioned in MQL4/Indicators: no supply wanted.
To seek out the buffer numbers, press Ctrl+D to open the Knowledge Window and hover over a bar with an arrow. The indicator’s values are listed so as, which normally maps to buffer 0, 1, 2. MQL4’s iCustom reads buffers 0 to 7, and a bar with no arrow normally returns EMPTY_VALUE (2147483647), although some indicators use 0.
The EA beneath reads a purchase and a promote buffer as soon as per bar at shift 1, the final closed bar, as a result of an arrow on the forming bar 0 can vanish earlier than the shut. That is the whole file: it compiled in MetaEditor with 0 errors and 0 warnings on 18 November 2026, and it locations no trades.
//+------------------------------------------------------------------+
//| ReadEx4Buffers.mq4 |
//| Reads two buffers of a compiled-only (.ex4) indicator as soon as per |
//| closed bar with iCustom. It locations no trades: it prints and |
//| alerts, so you may see what the indicator is basically telling you. |
//+------------------------------------------------------------------+
#property copyright "ForexMT4Indicators.com"
#property hyperlink "https://forexmt4indicators.com/ex4-vs-mq4/"
#property model "1.00"
#property description "Reads the purchase and promote buffers of a compiled indicator on every closed bar."
#property strict
//--- inputs
enter string InpIndicatorName = "MyArrows"; // Indicator file in MQL4/Indicators, with out .ex4
enter int InpBuyBuffer = 0; // Purchase arrow buffer (discover it within the Knowledge Window)
enter int InpSellBuffer = 1; // Promote arrow buffer
enter bool InpPopupAlert = true; // Pop-up alert when an arrow prints
datetime g_lastBarTime = 0;
void OnTick()
{
if(!IsNewBar())
return; // learn as soon as per bar, not on each tick
double purchase = 0.0, promote = 0.0;
// shift 1 = the bar that has simply closed; bar 0 remains to be forming and might change
if(!ReadBuffer(InpBuyBuffer, 1, purchase) || !ReadBuffer(InpSellBuffer, 1, promote))
{
g_lastBarTime = 0; // learn failed: strive once more on the following tick
return;
}
if(purchase != EMPTY_VALUE)
Sign("BUY", purchase);
if(promote != EMPTY_VALUE)
Sign("SELL", promote);
}
// Reads one buffer worth. Returns false if the indicator couldn't be learn.
// An empty arrow comes again as EMPTY_VALUE (some indicators use 0 as a substitute).
bool ReadBuffer(const int bufferIndex, const int shift, double &worth)
{
ResetLastError();
// No inputs are handed after the identify, so the indicator runs with its default settings
worth = 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(worth == 0.0)
worth = EMPTY_VALUE; // deal with 0 as "no arrow"
return(true);
}
int OnInit()
{
// MQL4 iCustom can learn buffer indexes 0 to 7 solely
if(InpBuyBuffer < 0 || InpBuyBuffer > 7 || InpSellBuffer < 0 || InpSellBuffer > 7)
{
Print("Buffer index should be between 0 and seven");
return(INIT_PARAMETERS_INCORRECT);
}
return(INIT_SUCCEEDED);
}
bool IsNewBar()
{
datetime t = Time[0];
if(t == g_lastBarTime)
return(false);
g_lastBarTime = t;
return(true);
}
void Sign(const string facet, const double value)
{
string msg = StringFormat("%s %s: %s arrow at %s on the closed bar",
_Symbol, EnumToString((ENUM_TIMEFRAMES)_Period), facet,
DoubleToString(value, _Digits));
Print(msg);
if(InpPopupAlert)
Alert(msg);
}
//+------------------------------------------------------------------+
With no inputs after the identify, the indicator runs on its defaults; when you modified any, go all of them of their authentic order. Then test the Consultants tab: every logged value ought to match an arrow on the chart. An arrow the EA logged that later vanishes means the indicator repaints, as our information to repainting indicators explains. One it by no means logged normally means it repaints or back-paints the arrow onto an older bar; first rule out a improper buffer quantity or arrows drawn as chart objects.
For the buying and selling half, see our step-by-step information to creating an Professional Advisor.
Gold notice. The EA reads _Symbol, so it really works unchanged on XAU/USD no matter your dealer calls gold (XAUUSD, GOLD or a suffixed identify), and it prints costs with the image’s personal decimals.
3. Wrap it for alerts
Within the EA’s Sign() perform, swap Alert(msg) for SendNotification(msg). When you tick Allow Push notifications and enter your MetaQuotes ID underneath Instruments > Choices > Notifications, every sign reaches the MT4 app in your telephone. This works provided that the indicator retains its alerts in buffers somewhat than chart objects, and doesn’t repaint.
4. Have a brand new device rebuilt from its behaviour
For various logic, or the indicator on MT5, the compiled file is a lifeless finish. Describe what it attracts and when, with screenshots, and a brand new indicator might be written from scratch to behave the identical, leaving you with supply code you personal. Desire to skip code on the buying and selling facet? Our comparability of no-code EA builders covers that route.
EX5 vs MQ5: does MT5 work the identical means?
MT5 works the identical means. An .mq5 is MQL5 supply code and an .ex5 is the compiled program MT5 runs, with the identical one-way compile. Our overview of the MetaTrader 5 platform covers its wider function set.
The information don’t cross over. An .ex4 by no means runs on MT5, and MT5’s iCustom wants a compiled .ex5 (usually in MQL5/Indicators). Transferring from .mq4 to .mq5 is a rewrite, not a rename: MQL4’s iCustom returns a worth, whereas MQL5’s returns a deal with you learn with CopyBuffer.
Nonetheless selecting a platform? Begin with our MetaTrader 4 platform information.
Why received’t my EX4 file load?
Test the Consultants and Journal tabs of the Terminal window (Ctrl+T) first, as a result of the error line normally names the trigger:
- Flawed folder. It belongs in
MQL4/Indicatorsinside the info folder, not this system folder; refresh the Navigator afterwards. On a Mac, learn putting in MetaTrader 4 on a Mac first. - It wants DLL imports. It is not going to run till you tick Permit DLL imports on its Frequent tab, and the DLL normally goes in
MQL4/Libraries. Learn the following part first. - Lacking companion indicators. A “can’t open file” line naming an .ex4 you shouldn’t have means it calls one other indicator by way of iCustom; set up that one too.
- Constructed for a more moderen terminal. MetaQuotes’ construct 970 launch notes (June 2016) state that “EX4 packages compiled in construct 970 and above is not going to run in previous terminal builds”. Replace MT4.
- Flawed platform. An .ex5 by no means hundreds in MT4, and an .ex4 by no means hundreds in MT5.
Is it secure to permit DLL imports?
Permit DLL imports just for information from authors you belief. With out DLLs, MQL4 code is fenced in (its file capabilities work solely contained in the MQL4/Information sandbox and the terminals’ shared Frequent/Information folder), however a DLL is unusual Home windows code with no such limits. MetaQuotes itself labels the choice “doubtlessly harmful, allow just for trusted functions”.
By no means tick it for an .ex4 from a Telegram group or a “free cracked EA” website. Allow it per program on the Frequent tab, because the Instruments > Choices setting is simply the default for newly hooked up packages. An arrow indicator that calls for DLL entry owes you an evidence.
Quite have it constructed?
Our growth group can flip an indicator into an EA, together with many compiled .ex4 indicators that expose their alerts, or rebuild a compiled indicator you purchased as a customisable new one. You get a set value earlier than you pay, with the supply code included.
Threat disclaimer: Foreign exchange and CFD buying and selling carries a excessive degree of danger and will not be appropriate for all merchants. The methods and indicators described on this article are instructional. Previous efficiency doesn’t assure future outcomes. At all times check on a demo account earlier than risking actual capital.
Regularly requested questions
Do I would like each the EX4 and MQ4 information?
No. MT4 runs the .ex4 by itself, so a compiled-only obtain works usually. The .mq4 is simply wanted to learn or change the code. When you have solely the .mq4, open it in MetaEditor and press F7 to create the .ex4.
Which is best, EX4 or MQ4?
Neither runs higher: MT4 runs the .ex4, which is compiled from the .mq4. The .mq4 is the extra helpful file to personal, as a result of it allows you to learn the logic, repair a bug, add an alert or have the device rewritten for MT5. When a obtain affords each, hold the .mq4.
How do I set up an EX4 file in MT4?
In MT4, select File > Open Knowledge Folder and replica the .ex4 into MQL4/Indicators, or MQL4/Consultants for an Professional Advisor. Again in MT4, right-click the Navigator’s record and select Refresh, then drag the indicator onto a chart. Our information to putting in MT4 indicators walks by way of every step.
Can I open an EX4 file in MetaEditor?
No. MetaEditor works with supply information (.mq4, .mq5 and .mqh), and an .ex4 holds no readable code. You’ll be able to nonetheless connect it in MT4 and alter each setting on its Inputs tab, however altering the logic wants the .mq4 from the creator.
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 seems in the identical folder because the supply. Refresh the MT4 Navigator and the indicator is able to connect.
Is there a free EX4 to MQ4 decompiler that works?
Not one you must use. MetaQuotes says EX4/EX5 information are reliably protected against decompilation, with safety rebuilt in construct 600 (February 2014), and decompiling another person’s file normally breaches the licence it got here with and might infringe the creator’s copyright. Ask the creator for the supply, or have a brand new device constructed from its behaviour.
Are EX4 information secure?
With out DLL imports, an .ex4 is fenced in: its file capabilities solely attain the MQL4/Information sandbox and the terminals’ shared Frequent/Information folder. An Professional Advisor can nonetheless place trades when AutoTrading is on and reside buying and selling is allowed in its settings, so check any new EA on a demo account first. Permit DLL imports just for authors you belief.
Can I take advantage of an MT4 EX4 indicator on MT5?
No. MT5 runs .ex5 information, and an .ex4 can’t be transformed as a result of there isn’t any supply to work from. With the .mq4, a developer can rewrite it in MQL5; with out it, the clear possibility is a brand new MT5 indicator constructed to behave the identical means.
Why is my indicator icon gray within the MT4 Navigator?
MetaQuotes’ assist says a gray diamond on a program icon means this system has no supply code file or couldn’t be compiled. If the indicator attaches and attracts usually, you normally have the .ex4 with out its .mq4; if an .mq4 is in MQL4/Indicators too, it’s failing to compile (press F7 on it in MetaEditor to see why).
Do I would like the MQ4 file to make use of an indicator in an EA?
No. MQL4’s iCustom reads the compiled .ex4 instantly from MQL4/Indicators. You want the buffer numbers, which the Knowledge Window (Ctrl+D) helps you discover, and the indicator should hold its alerts in buffers somewhat than drawing them as chart objects.
Discover foreign exchange dealer accounts
Go to these dealer web sites to test the account choices, regional availability and phrases that apply to you earlier than opening an account.
Buying and selling foreign exchange and CFDs carries a major danger of loss and isn’t appropriate for everybody. Dealer hyperlinks are affiliate hyperlinks; we might earn a fee when you use them.

