What is Decompiling?
Decompiling is the process of converting a compiled binary file back into a form that resembles its original source code. In the MetaTrader 4 (MT4) ecosystem, this usually refers to transforming an EX4 file (the compiled program) into an MQ4 file (the editable source code).
While the decompiled code is rarely identical to the original source — variable names, formatting, and comments are often lost — it can still reveal the program’s underlying logic and workflow. This makes decompiling a powerful but sensitive process, often sought by traders, developers, and programmers.
Understanding MQL4 and EX4/MQ4 Formats
To fully grasp decompiling, it’s important to understand the file formats used in MT4:
- MQL4 (MetaQuotes Language 4)
A C-like programming language used to write custom Expert Advisors (EAs), indicators, and scripts for MT4. Developers write their logic in MQ4 files. - MQ4 File
The editable source code file written in MQL4. It is where all the logic, functions, and comments are stored in human-readable format. - EX4 File
The compiled binary file generated from an MQ4 file. This is what MT4 actually executes. Users only need the EX4 file to run an EA, indicator, or script — but they cannot modify or study its internal workings without the source.
Thus, the relationship looks like this:
MQ4 (source code) → compiled → EX4 (executable code)
When Do Traders Consider Decompiling?
Traders and developers may seek to decompile EX4 files for various practical reasons, including:
- Modifying or Improving an EA/Indicator – To adjust trading logic, fix bugs, or enhance performance.
- Recovering Lost Source Code – When the original MQ4 file is missing but the EX4 file remains.
- Learning and Education – To understand how advanced EAs or indicators are structured in order to improve MQL4 programming skills.
- Conversion Purposes – For example, adapting an MT4 tool for use in MetaTrader 5 (MT5).
⚠️ However, these scenarios must always be weighed against legal and ethical considerations.
Using a Decompiler Tool
To perform decompilation, one typically needs a specialized decompiler tool. These tools attempt to reconstruct the MQ4 file from the EX4 binary.
But there are important caveats:
- Imperfect Results – Decompiled code may be difficult to read, with generic variable names (e.g., var1, func2) replacing the originals.
- Quality & Security Risks – Not all decompiler tools are safe. Many online downloads may contain malware or produce poor-quality results.
- Legal Concerns – Decompiling EX4 files created by other developers may infringe on MetaQuotes Software Corp’s intellectual property rights, as well as the copyrights of the original developer.
For these reasons, traders should only use decompilers when they have the legal right to do so, such as when recovering their own lost source code.
Important Notes & Alternatives
- You Don’t Always Need the Source Code
To build an EA that uses signals from an indicator, the source MQ4 file isn’t strictly required. A skilled MQL4 programmer can create a new EA that reads signals from an EX4 indicator and sends alerts, notifications, or places trades — without ever decompiling. - Rebuilding from Scratch
Often, a better approach than decompiling is to simply recreate the indicator or EA’s functionality based on its visible behavior. This ensures clean, maintainable, and fully legal code. - Learning MQL4
Instead of relying on decompiled code (which can be confusing), investing time into learning MQL4 programming can be far more rewarding.
Final Thoughts
Decompiling EX4 files into MQ4 format is a powerful but double-edged tool. On the one hand, it can help traders recover lost code, learn more about MQL4, and make improvements to their trading systems. On the other hand, careless or unauthorized use can raise serious legal and ethical issues.
If you choose to explore decompiling:
- Use it only for legitimate purposes (e.g., recovering your own source code).
- Be prepared for incomplete or messy output.
- Consider alternatives like rebuilding, signal extraction, or hiring an experienced MQL4 programmer.
Handled responsibly, decompiling can provide valuable insights into MT4 programs — but it should never be a shortcut for bypassing intellectual property rights or exploiting another developer’s work.
Visit