EX4 Decompiler: What It Is, How It Works, and When You May Need One
EX4 Decompiler: What It Is, How It Works, and When You May Need One
If you use MetaTrader 4 and have ever lost the source code for an Expert Advisor, indicator, or script, you may have come across the term EX4 decompiler.
An EX4 decompiler is associated with the analysis or recovery of compiled MQL4 applications. It is commonly discussed when someone has an .ex4 file but no longer has the original .mq4 source code.
However, EX4 decompilation is not simply a matter of changing a file extension.
The normal MQL4 development process goes in one direction:
MQ4 source code → compilation → EX4
Source-code recovery attempts to work in the opposite direction:
EX4 → analysis → reconstructed source
The result can vary significantly depending on the EX4 file, its compiler generation, protection, dependencies, and other technical characteristics.
This guide explains what an EX4 decompiler is, how EX4 files work, how source-code recovery differs from ordinary file conversion, when you may need an EX4 decompiler, and what to expect from the process in 2026.
What Is an EX4 File?
An EX4 file is a compiled MQL4 application designed to run on MetaTrader 4.
MQL4 is the programming language used to create MetaTrader 4 trading robots, custom indicators, scripts, and libraries. (MetaQuotes)
A developer normally starts with an MQ4 source file.
For example:
MyTradingRobot.mq4
The source is then compiled using MetaEditor.
The resulting executable can be:
MyTradingRobot.ex4
The simplified development process is:
MQ4
↓
MQL4 compiler
↓
EX4
↓
MetaTrader 4
The EX4 is intended for execution by MetaTrader 4 rather than direct human editing.
What Is an EX4 Decompiler?
An EX4 decompiler is a tool or recovery system designed to analyze a compiled EX4 application and attempt to reconstruct source-code-level information.
The important word is attempt.
A decompiler does not necessarily retrieve the original MQ4 file that the developer wrote.
Instead, it may analyze the compiled program and reconstruct programming structures that can then be represented as MQL4-style source.
A simplified concept is:
EX4 file
↓
File analysis
↓
Compiled-code analysis
↓
Program structure recovery
↓
Source reconstruction
↓
MQ4-style source
The resulting code can potentially be useful for maintenance, inspection, or further development.
However, the recovered source may look substantially different from the original MQ4.
EX4 Decompiler vs EX4 Converter
This distinction is important.
An ordinary converter might change:
JPG → PNG
The information is largely the same; only the representation changes.
EX4 source recovery is fundamentally different.
The original MQ4 may contain:
- comments
- variable names
- function names
- formatting
- source organization
- include files
- developer explanations
- high-level abstractions
Compilation transforms source code into a form intended for execution.
Therefore, recovering source from an EX4 is not equivalent to simply converting the file into another format.
Why Would Someone Need an EX4 Decompiler?
There are several situations in which someone may investigate EX4 source-code recovery.
1. You Lost the Original MQ4
This is one of the clearest use cases.
Imagine you developed an EA several years ago.
You still have:
MyEA.ex4
but the original:
MyEA.mq4
was deleted.
The EX4 may still run on MetaTrader 4, but without the MQ4 you cannot normally edit and recompile the original project in the same way.
Source recovery may provide a way to investigate whether useful source-level information can be reconstructed.
2. An Old Developer Is No Longer Available
A business may have commissioned an MT4 EA from a developer who is no longer available.
The company might still have the compiled EX4 but not the source project.
Depending on ownership and contractual rights, source-code recovery may be considered as part of a software-maintenance process.
3. You Need to Maintain Legacy Software
Older trading software can remain useful long after its original development environment has changed.
You may need to:
- fix a bug
- change an input
- update a calculation
- modify risk management
- change an indicator
- add functionality
If the MQ4 project is missing, recovering usable source may provide a starting point for maintenance.
4. You Want to Understand a Program You Own
A developer may have inherited an EX4 and need to understand its internal logic.
For example, you might need to determine whether an EA contains:
- time filters
- spread filters
- position-sizing rules
- stop-loss calculations
- take-profit calculations
- indicator conditions
- external DLL calls
Source recovery may help with that investigation, although the completeness of the recovered code depends on the file.
5. You Need to Rebuild a Lost Development Project
Sometimes the EX4 is the only remaining artifact of a larger project.
The original project may have contained:
EA.mq4
RiskManager.mqh
TradeFunctions.mqh
Utility.mqh
ExternalLibrary.ex4
If only the main EX4 remains, source recovery may be more complicated because the original project consisted of multiple components.
How Does an EX4 Decompiler Work?
The exact process depends on the technology being used, but it can be understood through several stages.
Stage 1: File Inspection
The EX4 is first analyzed as a compiled file.
The process may examine characteristics such as:
- file structure
- compiler generation
- executable information
- references
- strings
- program type
- protection characteristics
A damaged or incomplete EX4 can make recovery more difficult.
Stage 2: Compiler and Build Analysis
The MT4 build associated with an EX4 can be important.
MetaTrader 4 underwent a major MQL4 and compiler transition with Build 600, released in February 2014.
MetaQuotes introduced a revised MQL4 language, a unified compiler environment, a revised MetaEditor, and significantly revised protection for new EX4/EX5 applications. (MetaQuotes)
This means an EX4 from an older compiler generation should not automatically be treated as technically equivalent to a modern EX4.
Stage 3: Program Structure Analysis
A recovery system may attempt to identify information corresponding to:
- functions
- constants
- variables
- strings
- calculations
- program flow
- conditions
- calls
- trading operations
The goal is to reconstruct a representation of the program that is useful to a developer.
Stage 4: Source Reconstruction
The information identified during analysis can then be represented as MQL4-style source code.
The result may resemble:
int start()
{
double fastMA = iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, 0);
double slowMA = iMA(NULL, 0, 50, 0, MODE_EMA, PRICE_CLOSE, 0);
if(fastMA > slowMA)
{
// reconstructed trading logic
}
return(0);
}
This does not mean the original developer necessarily wrote the code exactly this way.
It represents what reconstructed source might look like.
Why the Recovered MQ4 May Look Different
This is one of the most important things to understand before using an EX4 decompiler.
Suppose the original source contained:
double fastMovingAverage;
double slowMovingAverage;
double maximumDailyRisk;
The recovered code may use different identifiers.
Likewise, it may not preserve:
- original comments
- formatting
- exact function organization
- original file structure
- developer naming conventions
Therefore:
Recovered source ≠ guaranteed original source
A recovery can still be useful even when it does not reproduce the original project exactly.
Does an EX4 Decompiler Recover Comments?
You should not assume that it will.
Comments are written for developers and are not required for the compiled program to execute.
For example, the original source might contain:
// Only trade during the London session
The compiled program may retain the underlying logic without providing a way to reproduce that exact explanatory sentence.
Consequently, recovered source may need new comments added manually.
Does It Recover Variable Names?
Not necessarily.
A developer may have used descriptive names such as:
maximumDailyDrawdown
while the recovered source may use another identifier.
After recovery, a developer can potentially rename variables to make the code easier to understand and maintain.
Why Build 600 Is Important
Build 600 is one of the most important milestones in the history of MQL4.
MetaQuotes described the release as a major revision of MQL4 and introduced:
- a unified compiler
- updated MQL4 functionality
- a unified MetaEditor
- revised file structure
- stronger protection for applications
- additional programming features
MetaQuotes specifically stated that protection of MQL4 applications was raised to the MQL5 level for newly compiled applications. (MetaQuotes)
This is why discussions about old “EX4 decompilers” need to distinguish between different generations of EX4 files.
Old EX4 Files and Build 600+
The Build 600 transition also changed how MQL4 files were stored.
Before the change, programs were commonly stored under the terminal installation’s experts structure.
After Build 600, MQL4 applications were moved into the terminal’s separate data folder and organized into directories such as:
MQL4\Experts
MQL4\Indicators
MQL4\Scripts
MQL4\Include
MQL4\Libraries
MetaQuotes documented that old EX4 programs were copied to the new location during the upgrade and were not automatically recompiled. (MQL5)
This is useful historical context when investigating an old EX4.
What About Modern EX4 Files?
Modern EX4 files should be evaluated separately from older files.
MetaQuotes continues to evolve MQL4 and the EX4 executable format. Its official documentation notes that the EX4 format has changed as new MQL4 features have been introduced. (MetaQuotes)
MetaTrader 4 is also still receiving platform updates.
For example:
- Build 1460 was released March 5, 2026.
- Build 1470 was released March 12, 2026. (MetaQuotes)
Therefore, a recovery method that worked with one historical EX4 should not automatically be assumed to work with every current EX4.
What Can Make EX4 Recovery Difficult?
Several factors can influence the result.
Compiler Generation
Different compiler generations can produce substantially different executable characteristics.
Protection
Compiled applications may use protection mechanisms that make analysis more difficult.
Obfuscation
Code can be structured to make its logic harder to understand.
Encryption or Packing
Additional protection can complicate analysis.
File Damage
A corrupted EX4 may not contain all the information needed for recovery.
Complexity
A small indicator may be considerably different from a large EA containing many modules.
External Dependencies
An EX4 may rely on:
- DLLs
- EX4 libraries
- MQH files
- external files
- resources
Recovering one EX4 does not automatically recreate these dependencies.
EX4 Decompiler for Expert Advisors
Expert Advisors are among the most common EX4 programs.
An EA can contain:
- market-entry conditions
- exit rules
- stop-loss logic
- take-profit logic
- trailing stops
- position sizing
- risk controls
- spread filters
- trading-session filters
- indicator calculations
- order-management functions
If you own an EA and lose the MQ4 source, recovering source-level logic can be valuable for maintenance.
But recovered trading code should always be tested before being used in a live environment.
EX4 Decompiler for Custom Indicators
Custom indicators can also be compiled into EX4.
They may contain:
- mathematical calculations
- buffers
- chart objects
- alerts
- custom signals
- trend calculations
- volatility calculations
Source recovery may help a developer understand or maintain an indicator when its MQ4 source is unavailable.
EX4 Decompiler for Scripts
Scripts are another type of MQL4 application.
They are commonly designed to execute an action once rather than continuously monitor the market.
Examples can include:
- chart utilities
- order-management scripts
- object-management tools
- data-processing utilities
MQL4 officially supports Expert Advisors, custom indicators, scripts, and libraries. (MetaQuotes)
What About DLL Dependencies?
DLLs require special attention.
A program can have a structure like:
EA
↓
EX4
↓
External DLL
↓
Windows
Recovering the MQL4 source does not automatically recover the source code inside the DLL.
If the DLL is required, the recovered EA may still depend on:
- the original DLL
- compatible DLL versions
- correct configuration
- appropriate terminal settings
What About MQH Files?
Large MQL4 projects often use include files.
For example:
TradingEA.mq4
↓
RiskManager.mqh
↓
TradeFunctions.mqh
↓
Utility.mqh
If these files are missing, the recovered source may require additional reconstruction or manual development.
How Do You Know Whether Recovery Worked?
Obtaining an MQ4 file is not necessarily the final test.
A better validation process is:
Recover → Compile → Backtest → Compare → Demo Test
Step 1: Compile the Recovered MQ4
Open the recovered source in MetaEditor.
Check for:
- compiler errors
- warnings
- undefined identifiers
- missing functions
- missing includes
- external references
Step 2: Resolve Dependencies
Check whether the original EX4 depended on:
- DLLs
- libraries
- include files
- external resources
- configuration files
Step 3: Backtest
If the program is an EA, use MetaTrader 4 Strategy Tester.
Compare the recovered EA under similar conditions.
Look at:
- trade entries
- exits
- stop losses
- take profits
- position sizing
- trade frequency
- indicator calculations
Step 4: Compare With the Original EX4
If you still have the original EX4, it is an important reference.
Run both versions under controlled conditions where possible.
The objective is to determine whether the recovered program behaves consistently with the original.
Step 5: Demo Test
Before using recovered trading software with real funds, test it in a demo environment.
A successful compilation does not prove that the recovered source behaves identically to the original.
Why Compilation Does Not Prove Behavioral Equivalence
Imagine an original EA contains:
Entry condition A
AND
Entry condition B
If the recovered code reconstructs the condition incorrectly, the EA may still compile successfully.
But it could generate different trades.
For trading software, this distinction is particularly important.
Compiles successfully ≠ identical behavior
When You May Need an EX4 Decompiler
An EX4 decompiler may be worth investigating when:
You lost your MQ4 source
This is perhaps the clearest situation.
You inherited an EX4 project
The previous developer may have provided only compiled files.
You need to maintain legacy software
The EA may still be useful but require modification.
You need to understand software you own
Source recovery may help document an old system.
You need to rebuild a development project
The EX4 may be the only remaining artifact.
When an EX4 Decompiler May Not Be the Right Solution
Source recovery is not always necessary.
For example, if you only need to run an existing EX4 and it already works correctly, you may not need MQ4 source at all.
Similarly, if the original developer still has the MQ4 project, obtaining the legitimate source from them may be preferable to reconstructing it.
If the goal is simply to change one small behavior, another option may be asking the original developer to make the modification.
How to Evaluate an EX4 Recovery Service
If you are considering an online or professional EX4 recovery service, look beyond marketing claims.
Ask about the file
Provide relevant information such as:
- EX4 file
- approximate MT4 build
- program type
- compilation date if known
- protection information if known
Ask about limitations
A credible service should explain that results can vary.
Be cautious of claims that imply every EX4 can be restored perfectly.
Ask about testing
Find out whether the recovered MQ4 is:
- compiled
- checked for errors
- tested
- compared with the original
Consider privacy
An EX4 may contain commercially valuable trading logic.
Before uploading it, review:
- file-retention policies
- deletion procedures
- access controls
- privacy terms
Online EX4 Decompiler vs Desktop Software
There are two broad approaches.
|
Option |
Main characteristic |
|
Desktop software |
Processing is performed locally |
|
Online recovery |
EX4 is uploaded for remote analysis |
|
Professional recovery service |
May include technical analysis and manual work |
|
Manual reconstruction |
Developer rebuilds missing logic |
The best approach depends on the EX4 and what you are trying to accomplish.
EX4 Decompiler in 2026
The EX4 environment in 2026 is not the same as the early MT4 environment.