Blog Details

thumb
21 Sep 2026

EX4 to MQ4 Decompiler: A Practical Guide to Recovering MetaTrader 4 Source Code

EX4 to MQ4 Decompiler: A Practical Guide to Recovering MetaTrader 4 Source Code

Finding an old MetaTrader 4 Expert Advisor with an EX4 extension but without its original MQ4 source code can be frustrating. You may have the working program, but without the editable source, making changes or maintaining the project can be difficult.

This is where the term EX4 to MQ4 decompiler comes into the picture.

EX4 and MQ4 are closely related, but they are not interchangeable file formats. MQ4 is associated with the source code used to develop MetaTrader 4 applications, while EX4 is the compiled version used by the MT4 terminal.

This article explains the difference between the two formats, why someone might need EX4 source-code recovery, what can affect the result, and what you should know before starting a recovery project.

EX4 vs MQ4: What Is the Difference?

The first step is understanding what each file represents.

MQ4: The Development Source

MQ4 is the source-code file associated with MQL4 applications.

Developers can use MQ4 files to create and maintain:

  • Expert Advisors
  • Custom indicators
  • Scripts
  • Automated trading systems
  • Trading utilities

Because MQ4 contains source code, developers can modify the program and compile a new version.

EX4: The Compiled Application

EX4 is the compiled version of an MT4 application.

The basic process is:

Write MQ4 → Compile → Produce EX4

The resulting EX4 is designed to be loaded and executed by MetaTrader 4.

This means that an EX4 file is not simply an MQ4 file with a different extension.

What Is an EX4 to MQ4 Decompiler?

An EX4 to MQ4 decompiler refers to software or a service that attempts to analyze a compiled EX4 application and reconstruct source-code information from it.

The purpose can be to produce a form of MQL4 source that can potentially be reviewed, compiled, modified, or used as a basis for rebuilding the original project.

However, it is important to distinguish source-code recovery from a normal file conversion.

There is no universal guarantee that the original MQ4 project will be reproduced exactly.

Why Would Someone Need to Decompile an EX4?

Source-code recovery can have several legitimate applications.

Recovering a Lost Trading System

Imagine developing an EA several years ago and losing the computer containing the original MQ4 file.

You may still have the compiled EX4 installed on an MT4 terminal or saved on a backup drive.

The EX4 may then be the remaining copy of the project.

Maintaining an Existing EA

An old Expert Advisor might still be useful but require modifications.

For example, you may want to change:

  • Trading parameters
  • Risk controls
  • Entry rules
  • Exit rules
  • Time filters
  • Alerts
  • Position management

Without the source code, normal development can be difficult.

Rebuilding Legacy Software

A company may inherit an MT4 system without receiving the original development project.

Analyzing the compiled application can help a developer understand what needs to be recreated.

Recovering Your Own Intellectual Property

If you created the original EA or indicator and still have the EX4 but lost the MQ4, source-code recovery may help preserve the project.

Is EX4 to MQ4 a Simple Conversion?

No.

A common misconception is that you can simply rename:

strategy.ex4

to:

strategy.mq4

That does not recover source code.

The contents of an EX4 are compiled. Renaming the extension does not reverse compilation.

A technical source-recovery process is required to analyze the compiled application.

Why the Original MQ4 May Not Be Reproduced Exactly

When developers write MQL4 source code, they can include:

  • Comments
  • Meaningful variable names
  • Function names
  • Formatting
  • Project structure
  • Documentation
  • Development notes

Compilation transforms the source into a compiled representation.

Consequently, some source-level information may not be available in its original form during recovery.

The resulting code may therefore look different from the source that was originally written.

What Can Influence Recovery Results?

Every EX4 file is different.

Several factors can affect the difficulty and potential result.

1. MetaTrader 4 Build

The MT4 build associated with the file can be an important technical factor.

Older and newer compiled applications may have different characteristics.

2. Compiler

The compiler used to create the EX4 can influence what information is available during analysis.

3. Protection

Some commercial applications may use protection or other mechanisms that make analysis more difficult.

4. Application Complexity

A small indicator may be considerably simpler to analyze than a large Expert Advisor with extensive trading logic.

5. Dependencies

An EX4 may rely on other files, libraries, or resources.

Recovering one EX4 does not automatically recover external components that were required by the original application.

EX4 to MQ4 for Expert Advisors

An Expert Advisor can contain a significant amount of trading logic.

For example, an EA might include:

  • Entry conditions
  • Exit conditions
  • Stop-loss calculations
  • Take-profit calculations
  • Lot-size calculations
  • Risk management
  • Indicator calculations
  • Trading-session filters
  • Spread checks
  • Position management
  • Alerts

If you are recovering your own EA, the goal may not simply be to obtain readable code. You may need source code that can actually be maintained and compiled.

That can require additional development after the initial recovery.

EX4 to MQ4 for Custom Indicators

The same principle applies to custom MT4 indicators.

An indicator may calculate market information and display it directly on a chart.

It could include:

  • Trend calculations
  • Signal generation
  • Price-level calculations
  • Moving averages
  • Volatility calculations
  • Alerts
  • Custom graphical elements

If the original MQ4 is missing, recovery can potentially provide information needed to rebuild or maintain the indicator.

EX4 Decompiler vs EX4 Converter

You may see both terms used when searching online.

An EX4 converter can sound like a standard file-format conversion tool.

An EX4 decompiler, however, generally refers to analyzing compiled software in an attempt to reconstruct source-code information.

This distinction matters because EX4 is not simply another document format.

What About EX5?

If you are working with MetaTrader 5, the file structure is different.

Platform

Source

Compiled

MT4

MQ4

EX4

MT5

MQ5

EX5

Therefore, if your file is .ex4, you are dealing with MetaTrader 4.

If your file is .ex5, you should investigate MetaTrader 5 and MQ5-related options instead.

How to Check Your EX4 File

Before contacting a source-recovery provider, collect basic information about the file.

Useful information includes:

  • File extension
  • File size
  • MT4 build
  • EA or indicator type
  • File age, if known
  • Related files
  • Whether you have any original source
  • What changes you need to make

This can help establish what type of technical assistance is appropriate.

What Happens After Recovery?

Obtaining reconstructed source code does not necessarily mean the project is finished.

A typical development process can involve several stages.

Source Review

The developer reviews the reconstructed MQ4 and identifies missing or problematic sections.

Compilation

The source is opened in MetaEditor and compiled.

Error Correction

Compilation errors and warnings may need to be addressed.

Dependency Review

External indicators, libraries, or other resources may need to be restored.

Functional Testing

The reconstructed version should be tested to determine whether it behaves as expected.

Testing an Recovered Expert Advisor

Testing is especially important when dealing with automated trading software.

A recovered EA should ideally be evaluated before being used with real funds.

Testing can include:

  • MT4 Strategy Tester
  • Historical data
  • Demo trading
  • Parameter testing
  • Entry/exit verification
  • Risk-management checks
  • Order-management checks

The objective is to determine whether the reconstructed version behaves consistently with the available original application.

How to Protect Your Source Code After Recovery

Once your MQ4 source has been recovered or recreated, avoid storing the only copy on one computer.

Consider maintaining multiple backups.

For example:

Primary development copy

→ Cloud backup

→ External storage

→ Version-control repository

You should also preserve important libraries, configuration files, documentation, and older working versions.

Legal Considerations for EX4 Decompilation

Before analyzing an EX4, make sure you have the appropriate rights or authorization.

An EX4 can contain proprietary software belonging to a developer or company.

Source-code recovery should not be used to copy, redistribute, resell, or modify another person’s proprietary software without permission.

If the EX4 is your own software, or you have authorization from the rights holder, source-code recovery can be considered as part of a legitimate maintenance or recovery project.

Frequently Asked Questions

What does EX4 to MQ4 mean?

It generally refers to attempting to recover or reconstruct MQL4 source-code information from a compiled MetaTrader 4 EX4 file.

Can an EX4 file be opened as MQ4?

No. EX4 is compiled software, while MQ4 is source code. Simply changing the extension does not convert the file.

Can every EX4 be recovered?

There is no guarantee. Results depend on the individual file, its build, compilation characteristics, protection, and complexity.

Will the recovered source be exactly the same?

Not necessarily. Reconstructed source can differ from the original in naming, formatting, comments, and program structure.

Can I recover an EA I created?

If you own the EA and have its EX4 file, source-code recovery may be an option worth investigating.

Can I modify an EX4 directly?

EX4 is not intended to be edited like an MQ4 source file. If you need substantial changes, appropriate source code or redevelopment is generally required.

Is EX4 used by MT4 or MT5?

EX4 is associated with MetaTrader 4. MetaTrader 5 uses EX5 for compiled applications.

Should recovered code be tested?

Yes. Particularly for Expert Advisors, recovered source should be compiled and tested carefully before any live deployment.

Final Thoughts

An EX4 to MQ4 decompiler can be relevant when you have a compiled MetaTrader 4 application but no longer have access to its original source project.

Whether you are recovering a lost EA, maintaining an old indicator, rebuilding a legacy trading application, or investigating software you own, the first step is understanding what information is actually available inside the EX4.

Source recovery is not the same as changing .ex4 to .mq4, and the final result may require additional development and testing.

If you own the software or have permission to analyze it, an assessment of the specific EX4 file can help determine the most appropriate path toward recovering or rebuilding the source.

Have an EX4 file without its MQ4 source? Gather the EX4, identify the MT4 build if possible, and establish exactly what you need the recovered source to accomplish before beginning the project.