EX4 Decompiler: The Complete Beginner’s Guide to EX4 Files, MQ4 Source Code and Expert Advisors
EX4 Decompiler: The Complete Beginner’s Guide to EX4 Files, MQ4 Source Code and Expert Advisors
If you are new to MetaTrader 4, you may have encountered files ending in .EX4, .MQ4, or .MQH and wondered what they mean.
You may also have searched for an EX4 decompiler because you have an EX4 Expert Advisor, indicator, or script but no longer have the original source code.
Understanding the difference between these files is the first step.
An EX4 file is a compiled MQL4 application. MQ4 is source code that developers can edit and compile into an EX4 program. MetaQuotes’ documentation explains that compilation converts MQL4 source code into an executable EX4 file, while the resulting executable does not expose the original source program in the normal editing workflow. (metatrader5.com)
This beginner’s guide explains what EX4 files are, what an EX4 decompiler means, how MQ4 source code relates to EX4, how Expert Advisors work, why MT4 builds matter, and what to understand before considering source-code recovery.
What Is an EX4 File?
An EX4 file is a compiled program used by MetaTrader 4.
It can represent different types of MQL4 applications, including:
- Expert Advisors
- Custom indicators
- Scripts
- Libraries
The .ex4 extension alone does not tell you exactly which type of program it is. Its location and how it is used inside MT4 provide additional context. (book.mql4.com)
For example, an Expert Advisor might appear as:
MyTradingEA.ex4
A custom indicator might be:
TrendIndicator.ex4
And a script could be:
TradeManager.ex4
All three are EX4 files, but they can perform completely different functions.
What Is MQ4 Source Code?
MQ4 is the source-code format used for MQL4 programs.
A developer can write an Expert Advisor in an MQ4 file, open it in MetaEditor, compile it, and generate an EX4 application.
The simplified process looks like this:
MQ4 source code
↓
Compiler
↓
EX4 compiled program
↓
MetaTrader 4
MetaQuotes describes compilation as the process of converting MQL4 source code into the executable EX4 format. (metatrader5.com)
Simple Example
A developer may have:
MyEA.mq4
After compilation, MetaEditor can produce:
MyEA.ex4
The MQ4 is the editable development source.
The EX4 is the compiled application intended to run in MetaTrader 4.
EX4 vs MQ4: The Difference
|
Feature |
MQ4 |
EX4 |
|
Source code |
Yes |
No normal editable source |
|
Editable in MetaEditor |
Yes |
No |
|
Designed to run in MT4 |
After compilation |
Yes |
|
Human-readable |
Generally |
Not as source code |
|
Used for development |
Yes |
No |
|
Used for distribution |
Sometimes |
Commonly |
This distinction is important when someone says:
“I have the EA, but I lost the source.”
They may still have the working EX4 application, but they no longer have the original MQ4 development file.
What Is an EX4 Decompiler?
An EX4 decompiler generally refers to software or a service intended to analyze a compiled EX4 program and reconstruct source-code information.
The term can be misleading because it may sound like a normal file converter.
It is not.
Converting:
document.pdf
to another document format is fundamentally different from attempting to reconstruct source code from compiled software.
An EX4 decompiler or recovery process attempts to work backwards from compiled program information.
Is EX4 to MQ4 a Simple Conversion?
No.
Renaming:
MyEA.ex4
to:
MyEA.mq4
does not turn the compiled application into source code.
The extension changes, but the contents do not become the original MQL4 source.
The original MQ4 project may also contain information that is not represented in the same form in the compiled EX4, such as:
- Comments
- Original variable names
- Formatting
- Project organization
- Include files
- Developer documentation
- External dependencies
Therefore, EX4 source-code recovery and EX4-to-MQ4 file conversion should not be treated as the same thing.
What Does an EX4 Decompiler Try to Recover?
Depending on the individual file and technical approach, source-code recovery may attempt to reconstruct elements such as:
- Program structure
- Functions
- Conditions
- Calculations
- Inputs
- Trading operations
- Indicator calculations
- Program logic
But reconstruction should not automatically be interpreted as recovery of the exact original development project.
For example, a recovered file could have different:
- Variable names
- Function names
- Comments
- Formatting
- Structure
- Supporting files
The important question is whether the resulting source is sufficiently usable for the intended purpose.
What Is an Expert Advisor?
An Expert Advisor, commonly called an EA, is a program designed to automate trading-related operations in MetaTrader 4.
An EA can contain rules for:
- Market analysis
- Entry conditions
- Exit conditions
- Stop-loss
- Take-profit
- Position sizing
- Risk management
- Trading schedules
- Alerts
- Indicator calculations
For example, an EA might be programmed to monitor EUR/USD and take an action when several predefined conditions occur.
The exact behavior depends entirely on the program’s source code.
Why Would Someone Need an EX4 Decompiler?
There are several legitimate situations where a software owner may investigate source-code recovery.
1. Lost MQ4 source code
Perhaps you still have the working EX4 but accidentally deleted the MQ4.
2. Original developer is unavailable
A developer may have stopped responding, closed a business, or become unavailable.
3. Legacy trading software
A business may still depend on an older EA or indicator but no longer have the original development project.
4. Maintenance
You may need to understand or modify an old application.
5. Compatibility work
An older application may need to be evaluated in a newer MT4 environment.
6. Documentation
You may want to understand how an old application operates before maintaining it.
What Is an MQH File?
Another file beginners often encounter is:
.mqh
MQH files are include/source files used by MQL4 programs.
For example, an MQ4 project could contain:
MyEA.mq4
TradingFunctions.mqh
RiskManagement.mqh
Indicators.mqh
The main MQ4 file may rely on functions or definitions contained in the MQH files.
This means that recovering or rebuilding an MQ4 file without its supporting files may leave part of the original project missing.
MetaQuotes documents MQH files as source components that can be included in MQL4 applications during compilation. (book.mql4.com)
What About EX4 Libraries?
EX4 files can also be used as libraries.
A larger project may therefore look something like:
MainEA.ex4
TradingLibrary.ex4
IndicatorLibrary.ex4
Support.dll
The main EA may rely on these components.
This is why an EX4 assessment should consider the entire application rather than looking only at one filename.
What Is a DLL in an MT4 Project?
Some MQL4 applications interact with external DLLs.
A DLL is a Windows dynamic-link library that can provide functionality outside the MQL4 program itself.
If an EA depends on a DLL, recovering or rebuilding only the EX4 may not reproduce the complete application.
You should therefore preserve any related DLLs that you legitimately possess.
Why MT4 Build History Matters
MetaTrader 4 has changed significantly over its history.
One of the most important milestones was Build 600, released in February 2014.
MetaQuotes described Build 600 as a major revision of MQL4, introducing a unified compiler and MetaEditor environment, changes to the MQL4 language and file structure, and revised protection for new EX4/EX5 applications. (MetaQuotes)
This matters when investigating an old EX4.
An EX4 from an older MT4 environment should not automatically be assumed to have exactly the same technical characteristics as an EX4 created with a later compiler.
Build 509 vs Build 600+
For beginners, it is useful to understand the broad historical distinction.
Older MQL4 environment
MT4 Build 509 and earlier used the older MQL4 compiler and file structure.
Build 600 and later
The MQL4 development environment was substantially revised.
MetaQuotes introduced:
- A unified compiler
- Updated MQL4 language features
- A new MetaEditor environment
- Revised file structure
- New development features
- Revised protection for new EX4/EX5 files (MetaQuotes)
This is one reason the approximate age and compiler history of an EX4 can be useful when investigating source-code recovery.
Does Your Current MT4 Build Tell You the EX4’s Build?
Not necessarily.
This is a common beginner mistake.
Suppose your MT4 terminal currently shows:
Build 14xx
That does not prove your EX4 was created with that exact build.
The EX4 may have been compiled years earlier and then copied into your current MT4 installation.
MetaQuotes documented that older EX4 applications could continue to work after the Build 600 transition without automatically being recompiled. (MQL4 Reference)
Therefore:
Current terminal build ≠ necessarily EX4 compiler build.
Can You Identify an EX4’s Exact Compiler Version?
Not always.
You can gather clues from:
- File history
- File timestamps
- Original developer information
- Old MT4 installations
- Related MQ4 files
- Technical file analysis
- Historical documentation
But these clues do not necessarily establish the exact compiler version with certainty.
If you are requesting professional source-code recovery, providing the original EX4 is usually more useful than trying to guess its build from the filename.
Can Every EX4 Be Decompiled?
You should be cautious about absolute claims.
It is not appropriate to assume that every EX4 can be perfectly converted into the original MQ4 source.
At the same time, simply seeing an EX4 file does not tell you everything about what technical analysis may or may not be possible.
MetaQuotes explicitly states that compilation produces an executable EX4 format that hides the original program algorithm. (metatrader5.com)
The practical answer is:
Recovery is file-specific.
Factors can include:
- Compiler generation
- Protection
- Program complexity
- Dependencies
- External libraries
- Available supporting files
- Desired recovery result
Why Exact Source-Code Recovery Can Be Difficult
The original developer may have had a complete project such as:
TradingSystem/
├── MainEA.mq4
├── Risk.mqh
├── Indicators.mqh
├── TradeFunctions.mqh
├── Settings.set
├── SupportLibrary.ex4
└── External.dll
But you might only have:
MainEA.ex4
Even if source information can be reconstructed from the EX4, the complete original project may not be present.
This distinction is important.
Recovered Source vs Original Source
These terms should not be confused.
Original source
The exact MQ4/MQH project created and maintained by the original developer.
Reconstructed source
Source code produced by analyzing the compiled application.
Reconstructed code may be usable while still differing from the original.
Replacement software
A developer may instead build a new application that reproduces documented behavior.
That is a software-development project rather than simply recovering the original source.
How to Prepare an EX4 for Assessment
If you legitimately own or have authorization to analyze the file, preserve the original first.
Step 1: Make a backup
Keep an untouched copy.
Step 2: Identify the application
Determine whether it is:
- Expert Advisor
- Indicator
- Script
- Library
Step 3: Gather related files
Look for:
- MQ4
- MQH
- EX4 libraries
- DLL files
- .set files
- Configuration files
Step 4: Record the history
Write down:
- When you obtained the EX4
- Who created it
- Where you obtained it
- Which MT4 terminal originally used it
- Whether you have an old computer or backup
Step 5: Define your goal
Decide whether you need:
- Editable source
- Maintenance
- Bug fixing
- A new feature
- Compatibility work
- Behavioral reproduction
How to Test Recovered MQ4 Source
If source code is reconstructed, do not immediately use it on a live trading account.
Compile it
Open the source in MetaEditor and check for:
- Compilation errors
- Warnings
- Missing files
- Missing functions
- Missing libraries
Compare it with the original
If the original EX4 still works, compare behavior under controlled conditions.
Check:
- Same symbol
- Same timeframe
- Same inputs
- Same historical period
- Same trading conditions
Backtest an EA
Use MT4’s Strategy Tester to investigate whether the recovered program behaves similarly to the original.
Use a demo environment
Before live deployment, test the recovered software on a demo account.
Why Backtesting Matters
An EA can appear to work while still containing important differences from the original.
For example, small changes to:
- Entry conditions
- Stop-loss calculations
- Position sizing
- Spread handling
- Indicator values
- Exit rules
can produce substantially different results.
Therefore, source-code recovery should be followed by functional validation.
EX4 Decompiler vs EX4 Converter
These terms are sometimes used interchangeably online, but they describe different concepts.
EX4 converter
Usually refers to changing or transforming a file between formats.
EX4 decompiler
Generally refers to attempting to reconstruct source information from compiled code.
EX4 source-code recovery
A broader term that can include technical analysis, reconstruction, correction, compilation, and testing.
For people searching for a lost MQ4 file, source-code recovery is often a more accurate description of the overall project.
What Should You Look for in an EX4 Recovery Service?
If you are considering a service, avoid judging it only by marketing claims.
Ask:
Do they assess the actual file?
A serious assessment should consider your particular EX4 rather than making the same promise for every file.
What will you receive?
Clarify whether the deliverable is:
- MQ4 source
- Reconstructed source
- Compilation assistance
- Dependency analysis
- Testing
- Documentation
What happens if dependencies are missing?
This can be particularly important for older Expert Advisors.
How is the file handled?
If the EX4 contains proprietary trading logic, understand how uploaded files are stored and handled.
What are the limitations?
A transparent service should explain that recovery results can vary.
Common Beginner Mistakes
Mistake 1: Renaming
.ex4
to
.mq4
This does not recover the source.
Mistake 2: Assuming EX4 is the same as MQ4
EX4 is compiled; MQ4 is source.
Mistake 3: Assuming every EX4 is recoverable
There is no universal guarantee.
Mistake 4: Ignoring MQH files
Supporting source files can be essential to the original project.
Mistake 5: Ignoring DLL dependencies
External components can affect how the application works.
Mistake 6: Using recovered code immediately
Always compile and test first.
Mistake 7: Forgetting authorization
Having an EX4 file does not automatically give you rights to reproduce or reverse engineer someone else’s software.
Frequently Asked Questions
What is an EX4 file?
An EX4 file is a compiled MQL4 application used by MetaTrader 4. It can represent an Expert Advisor, indicator, script, or library. (book.mql4.com)
What is an MQ4 file?
An MQ4 file contains MQL4 source code used to create MetaTrader 4 programs.
What is an EX4 decompiler?
An EX4 decompiler generally refers to software or a service intended to analyze a compiled EX4 and reconstruct source-code information.
Can I convert EX4 directly to MQ4?
No. Renaming or ordinary file conversion does not restore the original source code.
Can I edit an EX4 file in MetaEditor?
EX4 is the compiled application rather than the normal editable source. Development changes are normally made to MQ4 source code and then compiled again. (metatrader5.com)
What is an Expert Advisor?
An Expert Advisor is an MQL4 program designed to automate trading-related operations in MetaTrader 4.
Does Build 600 matter?
Yes. Build 600 introduced major changes to MQL4, including a revised language, unified compiler environment, changed file structure, and revised protection for new EX4/EX5 applications. (MetaQuotes)
Does my current MT4 build tell me when my EX4 was compiled?
Not necessarily. The EX4 may have been compiled using a different terminal or compiler and later copied to your current MT4 installation.
Can every EX4 be recovered?
There is no universal guarantee. Recovery depends on the individual file, its history, structure, protection, dependencies, and the desired outcome.
Will recovered MQ4 be exactly the same as the original?
Not necessarily. Reconstructed source may differ from the original in names, comments, formatting, structure, and other development details.
Should I use recovered source code on a live trading account?
No. Compile it, inspect it, compare behavior, backtest where appropriate, and test it in a demo environment before considering live use.
Final Thoughts
For beginners, the most important thing to understand is simple:
MQ4 is source code. EX4 is the compiled application.
An EX4 file can be an Expert Advisor, indicator, script, or library, while the original MQ4 project is what developers normally use to edit and maintain the program.
MetaQuotes’ Build 600 update was a major turning point in MQL4 development, introducing a unified compiler and substantial language, file-structure, and protection changes. (MetaQuotes)
If you have an EX4 but lost the MQ4, do not assume that renaming the file or using a generic converter will solve the problem.
Instead:
Preserve the EX4 → identify the application → gather dependencies → establish its history → assess the file → define your recovery goal → reconstruct where appropriate → compile → test → validate.
And if the EX4 belongs to someone else, make sure you have the necessary authorization before attempting source-code recovery.
Understanding these basics will make it much easier to evaluate EX4 decompiler claims, source-code recovery options, and MetaTrader 4 Expert Advisor projects.