EX4 to MQ4 Decompiler: What to Know Before Recovering an MT4 Source Code
EX4 to MQ4 Decompiler: What to Know Before Recovering an MT4 Source Code
Losing the source code of an MT4 Expert Advisor or indicator can be frustrating. You may still have a working EX4 file, but without the original MQ4 project, making changes or maintaining the software can become difficult.
This is where searches for an EX4 to MQ4 decompiler usually begin.
However, source-code recovery is not as simple as renaming an EX4 file or converting it with an ordinary file converter. Different EX4 files can have very different levels of recoverability, particularly when they involve copy-trading functions, external DLLs, encryption, or software protection.
This article explains the important factors to consider before starting an EX4 source-code recovery project.
You Have the EX4 but Lost the MQ4 — What Now?
Imagine you have an Expert Advisor that has been running successfully for years.
The original developer is no longer available.
The computer containing the source code has been replaced.
The backups are missing.
But you still have:
TradingEA.ex4
The EA continues to work inside MetaTrader 4, but you cannot open it as normal editable MQL4 source code.
This is one of the situations where source-code recovery may be considered.
The first question should not be:
“Which decompiler should I use?”
A better question is:
“What can realistically be recovered from this particular EX4?”
That distinction can save time and prevent unrealistic expectations.
EX4 Files Are Not All the Same
Two EX4 files can look identical from the outside while being completely different internally.
One may be a relatively straightforward indicator.
Another may be a sophisticated Expert Advisor containing:
- Complex trading logic
- Multiple modules
- External libraries
- DLL calls
- Licensing checks
- Encryption
- Obfuscation
- Account restrictions
- Communication with remote servers
Consequently, the same recovery approach may not work equally well for every EX4.
Indicators vs Expert Advisors
An MT4 indicator generally processes market data and displays information on the chart.
An Expert Advisor can perform considerably more complex operations, including automated trade management.
For example, an EA may contain logic for:
- Entry signals
- Exit signals
- Position management
- Risk calculations
- Spread filtering
- Trading schedules
- News filters
- Multiple symbols
- Account restrictions
The more complex the application, the more work may be required to reconstruct and test its source code.
Copy-Trading EAs Add Another Layer
Copy-trading software deserves special attention.
A basic copy-trading setup might consist of:
Sender Account → Trade Information → Receiver EA → Receiver Account
The sender may generate information about a trade, while the receiving EA interprets that information and executes an equivalent or modified transaction.
But the exact implementation can vary considerably.
A copy-trading EA might use:
- Local files
- Shared folders
- Network communication
- Web services
- DLL libraries
- Multiple MT4 terminals
- VPS infrastructure
If the MQ4 source has been lost, understanding the communication mechanism becomes an important part of the recovery process.
Why Copy-Trading Source Code Matters
Without source code, modifying a copy-trading system can be difficult.
For example, you may want to change:
1. Lot Multiplier
Instead of copying the exact lot size, you may want the receiver to use a percentage of the original position.
2. Symbol Mapping
The master may trade one symbol while the broker uses a different symbol name.
3. Risk Controls
You may want additional limits on maximum lot size or number of simultaneous trades.
4. Trade Filtering
You may want to copy only certain symbols, magic numbers, or trade types.
These types of modifications generally require access to editable source code or a complete redevelopment of the system.
DLL Encryption Can Change the Situation
One of the most important things to identify before attempting recovery is whether the EX4 relies on an external DLL.
A DLL can contain functionality that the MQL4 program calls during execution.
The relationship may look like:
EX4 Program → DLL Function → External Processing
If the DLL is encrypted, protected, unavailable, or dependent on another licensing system, recovering the EX4 portion may not be enough to reproduce the original application.
Why DLL Dependencies Matter
Suppose an EA performs part of its operation through a DLL.
The reconstructed MQ4 may contain an external function call, but the actual functionality could remain inside the DLL.
That means a source recovery project may involve two separate components:
MQL4 Recovery
and
External Dependency Analysis
These should not automatically be treated as the same problem.
What Does a DLL-Protected EA Look Like?
A DLL-dependent EA may behave normally when running in MetaTrader 4 but fail when the required DLL is removed.
You may encounter errors or unexpected behavior when:
- The DLL is missing
- DLL permissions are disabled
- The DLL is protected
- The required version is unavailable
- The EA expects a specific environment
- A license verification system is involved
This is why it is useful to preserve the original EX4, DLLs, configuration files, and other dependencies together.
Don’t Judge Recovery by File Size
A common mistake is assuming that a larger EX4 must contain more recoverable source code.
File size alone is not a reliable indicator of recoverability.
A small EX4 may contain complicated logic.
A large EX4 may contain external resources or dependencies.
The more useful questions are:
- What type of application is it?
- What MT4 environment was it built for?
- Does it use external libraries?
- Is there protection?
- Is the file intact?
- What functionality needs to be restored?
What Does “Recovered Source Code” Actually Mean?
There are several possible outcomes from an EX4 source-code recovery project.
Full Reconstruction
The resulting MQ4 project contains enough recovered logic to reproduce the important functionality.
Partial Reconstruction
Some functionality can be reconstructed, while certain components remain unavailable or require manual redevelopment.
Functional Rebuild
Instead of reproducing the original source structure, a developer may recreate the required behavior using newly written MQL4 code.
This can be particularly useful when the original source structure is difficult to reconstruct but the expected behavior is known.
Testing Is More Important Than Appearance
A recovered MQ4 file may look convincing but still contain problems.
The real test is whether it performs correctly.
For an indicator, testing might involve comparing:
- Signals
- Indicator values
- Chart objects
- Alerts
- Timeframe behavior
For an Expert Advisor, testing can include:
- Entry conditions
- Exit conditions
- Stop-loss
- Take-profit
- Lot calculations
- Trade filters
- Risk management
- Magic numbers
For a copy-trading EA, communication and order replication should also be tested.
Why You Should Keep the Original EX4
Even after source recovery, never delete the original EX4.
Keep it as a reference version.
A useful recovery archive could contain:
Original EX4
Recovered MQ4
DLL Dependencies
Include Files
Configuration Files
Testing Notes
This makes future troubleshooting significantly easier.
Protecting Recovered Source Code
Once your MQ4 source has been recovered, protect it carefully.
A source-code loss can happen again through:
- Computer failure
- Accidental deletion
- Hosting problems
- Malware
- Hardware damage
- Lost storage devices
Keep multiple secure backups.
If the project is commercially important, maintain versioned backups so that previous working versions can also be restored.
Is an EX4 to MQ4 Decompiler Right for Every Project?
Not necessarily.
If you have the original MQ4, that should always be your preferred source.
If the MQ4 is permanently lost and you own or are authorized to work with the software, an EX4 source-code recovery assessment may be worthwhile.
The important thing is to determine the technical situation before making assumptions about the result.
A straightforward indicator may require a very different approach from a protected copy-trading EA that relies on an encrypted DLL.
Final Thoughts
Searching for an EX4 to MQ4 decompiler is often the beginning of a source-code recovery project, not the end of it.
The EX4 file, MT4 build, program complexity, copy-trading architecture, DLL dependencies, encryption, and protection mechanisms can all influence what can realistically be reconstructed.
If you have lost the MQ4 source code of your own MT4 software, preserve every related file before starting. Keep the original EX4, locate any DLLs and dependencies, and document how the program is expected to operate.
A careful assessment can then determine whether the project is suitable for source-code recovery, partial reconstruction, or a complete functional rebuild.
The goal should not simply be to obtain an MQ4 file. The goal is to recover a usable, testable, and maintainable MT4 project.