EX4 Decompiler: Complete Guide to EX4 Files, Decompilation and Source-Code Recovery
An EX4 decompiler is commonly searched for by MetaTrader 4 users who have an EX4 file but no longer have the original MQ4 source code.
The basic question is simple:
Can an EX4 file be converted or recovered back into editable MQ4 source code?
The technical answer is more complicated.
An EX4 file is a compiled MQL4 program, while MQ4 is source code used during development. The normal development process moves from MQ4 source to a compiled EX4 program. MetaQuotes’ documentation also separates MQL4 source files, include files and compiled EX4 libraries within the MT4 file structure. (MQL5)
When the original MQ4 source is lost, the problem becomes one of source-code recovery, reconstruction, analysis, or redevelopment rather than a simple file conversion.
This guide explains what EX4 files are, how compilation works, what decompilation means, why MT4 Build 600 changed the situation, what dependencies can affect recovery, how recovered source should be tested, and what you should realistically expect from an EX4 recovery project.
Important: EX4 analysis and source recovery should only be performed on software you own or are authorized to analyze. This guide focuses on legitimate source recovery and technical understanding rather than bypassing licensing, authentication, or software protection.
What Is an EX4 File?
An EX4 file is the compiled form of an MQL4 application for MetaTrader 4.
MQL4 developers can create several types of programs, including:
- Expert Advisors
- Custom indicators
- Scripts
- Libraries
A simplified development process looks like this:
MQ4 source code → MetaEditor/compiler → EX4 program
The MQ4 file is intended for development and editing.
The EX4 file is the compiled program that MetaTrader 4 can execute.
That distinction is the foundation of understanding EX4 decompilation.
What Is an MQ4 File?
MQ4 is the source-code format associated with MQL4 development.
For example, an Expert Advisor might originally have been developed as:
MyTradingEA.mq4
The developer can modify the source and compile it to produce an executable:
MyTradingEA.ex4
The original MQ4 project may also have depended on other source files such as MQH include files.
Therefore, an MQ4 project can contain considerably more information than a single EX4 executable.
EX4 vs MQ4
|
Feature |
MQ4 |
EX4 |
|
Purpose |
Source development |
Program execution |
|
Human-readable |
Generally yes |
No, not as normal source |
|
Editable in MetaEditor |
Yes |
Not as normal source |
|
Compiled |
No |
Yes |
|
Used by MT4 |
Source for compilation |
Executable program |
|
Comments |
Can contain them |
Not guaranteed to preserve them |
|
Original project structure |
Available if project is complete |
Not necessarily preserved |
|
Can be recompiled |
Yes |
No, not as source |
The important point is that an EX4 should not be treated as an MQ4 file with a different extension.
What Does an EX4 Decompiler Do?
The term EX4 decompiler generally describes a tool or process intended to analyze a compiled EX4 and produce some form of higher-level representation or recoverable source.
Conceptually:
Original development
MQ4 → EX4
Attempted recovery
EX4 → reconstructed source
However, the second process is not necessarily a perfect reversal of compilation.
Compilation can transform the original source and discard or alter information that was useful to the developer.
Consequently, a recovered MQ4 may not be identical to the original MQ4.
Decompilation vs Source-Code Recovery
These terms are sometimes used as if they mean exactly the same thing.
They do not always describe the same objective.
Decompilation
Decompilation generally means attempting to translate compiled program information into a higher-level representation.
Source-Code Recovery
Source-code recovery focuses on obtaining enough information to recreate a maintainable source project.
Redevelopment
Redevelopment means creating new source code that reproduces the required behavior of the original application.
These approaches can overlap, but they should not be confused.
For a lost MT4 project, source reconstruction or redevelopment may sometimes be more realistic than claiming that the original source can be restored exactly.
Why Can’t You Simply Rename EX4 to MQ4?
One of the most common misconceptions is that an EX4 can be converted simply by changing its extension.
For example:
tradingbot.ex4
cannot become usable source code merely by renaming it:
tradingbot.mq4
The internal content remains compiled.
The filename extension does not change the underlying program representation.
If the original MQ4 is available, the correct approach is normally to edit that source and compile it again.
If only the EX4 exists, a separate recovery or reconstruction process is required.
How MQL4 Compilation Works
A simplified compilation process is:
Step 1 — Source
The developer creates MQ4 source.
Step 2 — MetaEditor
The source is opened and compiled using the MQL4 development environment.
Step 3 — Compilation
The compiler transforms the source into an executable representation.
Step 4 — EX4
The resulting EX4 can be loaded by MetaTrader 4.
The important consequence is that compilation is not necessarily reversible in the sense of restoring the exact original project.
What Can Be Lost During Compilation?
The original MQ4 may contain information such as:
- Comments
- Formatting
- Developer-chosen variable names
- Function organization
- File structure
- Documentation
- Development notes
- Unused source elements
- Original project organization
A recovered source file may therefore look very different from the original even when it implements similar behavior.
The Importance of MT4 Build History
One of the most important subjects in EX4 recovery is the MT4 build generation.
MetaTrader 4 underwent a major technical change around Build 600, released on February 3, 2014.
MetaQuotes described Build 600 as a major update involving the MQL4 language, MetaEditor, compiler environment, file structure and application protection. (MQL5)
This creates an important historical distinction between older EX4 files and newer EX4 files.
Build 509 and Older Programs
Older MQL4 applications were created using the earlier MQL4 environment.
The older terminal stored applications in directories such as:
experts
experts\indicators
experts\scripts
include
libraries
MetaQuotes documented how these files were handled when users upgraded to the newer MT4 environment. (MQL5)
Build 600 and Later
Build 600 introduced a substantially revised MQL4 development environment.
MetaQuotes also stated that protection of MQL4 applications was raised to the MQL5 level and that new EX4/EX5 files received substantially revised protection. (MQL5)
This is one reason modern EX4 recovery should not automatically be treated as equivalent to historical EX4 decompilation.
Is Every EX4 Decompilable?
No responsible recovery assessment should promise that every EX4 can be converted into the exact original MQ4.
This is particularly important for modern EX4 files.
MQL4 community discussions have repeatedly debated claims about modern EX4 decompilation. Some forum moderators have stated that there has been no publicly demonstrated general-purpose decompilation of EX4/EX5 files since Build 600, while other users have disputed those statements. These are community claims and debates, not a universal technical guarantee about every individual file. (MQL5)
The practical conclusion is:
Do not assume that an EX4 can always be recovered perfectly.
The actual file needs to be assessed.
What Does an EX4 Recovery Assessment Look At?
Before attempting any recovery project, several characteristics can be examined.
1. File Type
Is it:
- Expert Advisor?
- Indicator?
- Script?
- Library?
2. Age
When was it created?
Was it likely produced before or after Build 600?
3. Dependencies
Does it require:
- DLLs?
- EX4 libraries?
- MQH files?
- External indicators?
- Configuration files?
- Presets?
4. Functionality
What does the application actually do?
5. Supporting Files
Are there backups or other project components?
6. Required Outcome
Does the user need:
- Editable source?
- A specific modification?
- Functional redevelopment?
- Documentation?
- Migration to another environment?
These questions can significantly change the appropriate recovery approach.
EX4 Dependencies
An EX4 may be only one part of a larger MT4 application.
MetaQuotes’ MT4 file structure includes separate locations for:
- Experts
- Indicators
- Scripts
- Include files
- Libraries
- Files
- Presets
- Images
EX4 libraries can also provide functions that are dynamically called by other MQL4 programs. (MQL5)
This means an EA may not contain everything necessary to understand its complete functionality.
DLL Dependencies
A program may also communicate with external DLLs.
In that situation:
EX4 source recovery ≠ DLL source recovery
Recovering the MQL4-side functionality does not automatically provide the original source code of an external DLL.
EX4 Libraries
An EA may depend on another EX4 library.
For example:
MainEA.ex4
TradingLibrary.ex4
If the library is missing, understanding the main program may be more difficult.
MQH Include Files
The original source may also have used MQH include files.
For example:
MainEA.mq4
RiskManager.mqh
TradeFunctions.mqh
Indicators.mqh
The complete development project may therefore contain many files that are not represented by a single EX4.
EX4 Decompilation and Expert Advisors
Expert Advisors are among the most common reasons users search for EX4 decompilers.
An EA can contain:
- Entry logic
- Exit logic
- Stop-loss rules
- Take-profit rules
- Trailing stops
- Position sizing
- Risk management
- Indicator calculations
- Trading filters
- Session restrictions
- Order management
- Alerts
If the original MQ4 source is lost, recovering or reconstructing these components may allow the EA to become maintainable again.
However, the recovered implementation may not have the same internal structure as the original.
EX4 Decompilation and Indicators
Custom indicators can also be distributed as EX4 files.
An indicator might calculate:
- Moving averages
- Oscillators
- Custom signals
- Price transformations
- Statistical calculations
- Chart objects
If only the EX4 exists, recovering the underlying calculation logic may be more difficult than simply editing an existing MQ4 source file.
Testing is particularly important because small calculation differences can produce different chart signals.
EX4 Decompilation and Scripts
Scripts are another MQL4 application type.
They may perform one-time actions such as:
- Trade management
- Chart operations
- File processing
- Account utilities
- Order operations
Again, the recovery objective should be defined before any technical work begins.
Protected EX4 Files
Modern EX4 protection is an important factor.
MetaQuotes stated when Build 600 was introduced that the protection of MQL4 applications was substantially revised. (MQL5)
Community discussions also distinguish older partially byte-code-based MQL4 applications from newer MQL4+ applications. (MQL5)
Because of this history, online claims that a particular tool can guarantee complete recovery of every protected EX4 should be evaluated carefully.
A credible assessment should explain:
- What file was examined
- What recovery level is expected
- What dependencies exist
- What limitations apply
- Whether the result will be reconstructed source or original source
What Can Potentially Be Reconstructed?
Depending on the particular application, a source-recovery project may attempt to reconstruct information such as:
Trading Logic
- Entry conditions
- Exit conditions
- Order management
- Risk controls
Indicator Logic
- Calculations
- Buffers
- Signals
- Chart output
Parameters
- Input variables
- Risk settings
- Trading settings
Program Architecture
- Functions
- Control flow
- Dependencies
- External calls
The exact result varies from one EX4 to another.
What Usually Cannot Be Guaranteed?
A recovery project should not automatically promise:
- Original comments
- Original formatting
- Original variable names
- Original MQH files
- Original DLL source
- Original project organization
- Original developer documentation
- Identical source code
Even if the recovered program behaves similarly, its internal source can be different.
Source Recovery vs Redevelopment
Sometimes recovering the original architecture is not the most practical goal.
Suppose you have an old trading EA that:
- Still runs
- Produces known signals
- Has no MQ4 source
- Needs a new feature
Instead of attempting to reproduce every original implementation detail, a developer may create a new MQ4 project that reproduces the required behavior.
That is redevelopment.
It may be based on:
- Observed behavior
- Available documentation
- Existing inputs
- Trading history
- Indicator output
- User requirements
The resulting source is new code rather than the original source.
A Professional EX4 Source-Recovery Workflow
A structured workflow can make the process much more reliable.
Step 1: Collect Everything
Gather:
- EX4 files
- MQ4 backups
- MQH files
- DLL files
- EX4 libraries
- Presets
- Configuration files
- Documentation
- Screenshots
- Original installation files
Step 2: Identify the Program
Determine whether the file is an:
- EA
- Indicator
- Script
- Library
Step 3: Determine the Build Context
Establish what is known about:
- MT4 version
- Compiler generation
- Creation date
- Build 509 vs Build 600+
- Updates performed after creation
Step 4: Map Dependencies
Determine whether the program relies on:
- DLLs
- EX4 libraries
- Include files
- Other indicators
- External files
- External services
Step 5: Analyze the Available Program
The authorized technical analysis should determine what information is realistically available for recovery.
Step 6: Reconstruct or Redevelop
Depending on the results, the appropriate approach may be:
Source reconstruction
or
Functional redevelopment
Step 7: Compile
Compile the resulting MQ4 using an appropriate MQL4 environment.
Step 8: Test
Compare the recovered program with the original wherever possible.
Testing Recovered MQ4 Source
Testing should be treated as a separate stage from source recovery.
Compilation Test
First confirm that the MQ4 source compiles correctly.
Strategy Tester
Use MT4’s testing environment to compare historical behavior.
Demo Testing
Run the recovered EA in a demo environment before considering live use.
Behavioral Comparison
Compare:
- Entries
- Exits
- Stop losses
- Take profits
- Lot sizing
- Risk calculations
- Indicator signals
- Alerts
- Order management
Dependency Testing
Make sure required libraries, DLLs and external files are available and functioning as expected.
Why Compilation Alone Is Not Enough
A recovered MQ4 file can compile successfully and still behave differently from the original EX4.
For example:
Original:
Entry condition → 1.1050
Recovered:
Entry condition → 1.1052
A small difference may produce substantially different trading results over time.
Therefore:
Compiled successfully ≠ functionally identical
This is particularly important for automated trading systems.
How to Verify an EX4 Recovery
A practical verification process can compare the original and reconstructed programs.
Inputs
Do the same settings produce equivalent behavior?
Signals
Are signals generated under the same conditions?
Orders
Are order types and execution rules consistent?
Risk
Are lot sizes and risk calculations consistent?
Exits
Are stop-loss, take-profit and closing conditions equivalent?
Indicators
Do chart values and signals match?
Timing
Does the EA react at the same points in the trading cycle?
The more of these areas that can be tested, the more confidence you can have in the reconstructed application.
Common EX4 Decompilation Mistakes
Mistake 1: Renaming the Extension
Changing .ex4 to .mq4 does not recover source code.
Mistake 2: Assuming Every EX4 Is Recoverable
Build history, protection and dependencies matter.
Mistake 3: Ignoring Dependencies
A single EX4 may rely on other libraries or external components.
Mistake 4: Confusing Decompiled and Original Source
Recovered code may be reconstructed rather than identical to the original developer project.
Mistake 5: Skipping Testing
A compiling MQ4 is not automatically functionally equivalent.
Mistake 6: Trusting Guaranteed Claims
Claims such as “100% exact source from every EX4” should be treated cautiously, particularly for modern protected files.
When Should You Consider EX4 Source Recovery?
Source recovery may be useful when:
- The original MQ4 has been lost
- You own the software
- The original developer is unavailable
- You need to maintain an old EA
- You need to modify an inherited indicator
- You need to understand an old trading system
- You need to rebuild an MT4 application
- You need to migrate functionality
If you already have the original MQ4 project, working from that source is normally preferable.
What Should You Provide for an EX4 Assessment?
For an authorized recovery project, provide as much legitimate information as possible.
Files
- EX4
- MQ4
- MQH
- DLL
- EX4 libraries
- Presets
- Configuration files
Information
- MT4 build
- Approximate creation date
- Program type
- What the application is supposed to do
- What changes you need
Supporting Evidence
Useful information can include:
- Screenshots
- Documentation
- Old settings
- Previous versions
- Backups
- Test results
The additional information can help determine whether source recovery or redevelopment is more appropriate.
EX4 Decompiler FAQ
What is an EX4 decompiler?
An EX4 decompiler is a tool or technical process associated with analyzing compiled MetaTrader 4 EX4 programs and attempting to produce a higher-level representation or recoverable source.
Can an EX4 be converted directly to MQ4?
Not in the same straightforward way that MQ4 source is compiled into EX4. Recovery may involve analysis and reconstruction, and the original source is not guaranteed.
Can I edit an EX4 in MetaEditor?
Normal MQL4 development is performed on MQ4 source code. An EX4 is a compiled program rather than the normal editable source project.
Can every EX4 be decompiled?
There is no sound basis for promising perfect recovery of every EX4. Modern MQL4 protection and differences between compiler generations make the answer dependent on the individual file.
Does Build 600 matter?
Yes. Build 600 was a major MQL4 update that changed the language, development environment, file structure and application protection. (MQL5)
What is the difference between decompilation and redevelopment?
Decompilation attempts to recover a higher-level representation from compiled code. Redevelopment creates new source code that reproduces the required functionality.
Can DLL source code be recovered from an EX4?
Not automatically. DLLs are separate components and their source is distinct from MQL4 source.
Can an EX4 library be important?
Yes. MetaQuotes documents EX4 files as possible libraries that can be dynamically called by other MQL4 programs. (MQL5)
Will recovered MQ4 look exactly like the original?
Not necessarily. The source may have different names, formatting, comments and internal organization.
Should recovered MQ4 be tested?
Yes. It should be compiled and tested thoroughly, especially before use with live trading funds.
Final Conclusion
An EX4 decompiler is not simply an EX4-to-MQ4 file converter.
The normal MT4 development process is:
MQ4 source → compiler → EX4
When the source is lost, the problem becomes one of analyzing an existing compiled application and determining what can realistically be recovered or reconstructed.
The most important factors include:
- EX4 generation
- MT4 build history
- Compiler differences
- Protection
- Program complexity
- DLL dependencies
- EX4 libraries
- Supporting files
- Required functionality
The introduction of Build 600 in 2014 was particularly significant because MetaQuotes introduced major changes to MQL4, MetaEditor, the file structure and application protection. (MQL5)
For that reason, a professional EX4 recovery process should begin with assessment rather than promises.
The goal may be to recover usable source, reconstruct the application’s functionality, or redevelop the required MT4 system in maintainable MQ4.
And regardless of the recovery method, the final source should be compiled, tested and compared against the original program’s behavior before being relied upon for live trading.