An .mq4 file contains the raw source code written in the MetaQuotes Language 4 (MQL4). This is a human-readable text file. If you open an MQ4 file in MetaEditor (the built-in development environment for MT4) or even a standard text editor like Notepad, you will see the actual programming logic, variables, algorithms, and technical indicator setups.
Disclaimer: Trading foreign exchange on margin carries a high level of risk. This article is for educational purposes only and does not constitute financial advice.
If you are experiencing specific compilation issues, let me know. I can help you troubleshoot by reviewing the from your MetaEditor toolbox, inspecting the code snippet causing the failure, or identifying which version of MT4/MQL4 you are currently running. Share public link
When you attach an EA to a chart or drag an indicator onto a price window, you are actually running the EX4 file.
If you do not want to open MetaEditor manually, MetaTrader 4 features a built-in auto-compilation mechanism. Close your MT4 terminal. mq4 to ex4
This is the version that MetaTrader 4 actually uses. When you drag an Expert Advisor or Indicator onto a chart, the platform looks for the EX4 file to execute the commands.
MetaQuotes updated the MQL4 language compiler significantly to match MQL5 syntax structures. If you are trying to compile an older MQ4 file (written prior to Build 600), you may encounter hundreds of warnings or errors. You will need to manually update deprecated functions (like replacing old string functions or fixing strict mode violations). Frequently Asked Questions Can I convert EX4 back to MQ4?
An is the result of successfully translating the MQ4 source code. This is a compiled, executable file specifically designed for the MT4 environment. It is a binary, machine-code version of your program that is optimized for fast and efficient execution.
Include a function that pings your server. If the user’s license is revoked, your server command can disable the EA. Disclaimer: Trading foreign exchange on margin carries a
Before deploying a compiled .ex4 to a live account:
Here is a comprehensive guide on how to convert MQ4 to EX4, why it matters, and how to troubleshoot common compilation errors. Understanding the Difference: MQ4 vs. EX4
Paste it directly into the target MT4 data directory (e.g., MQL4/Experts or MQL4/Indicators ). Launch your MetaTrader 4 platform.
Many sellers use EX4 files combined with license keys (via .dll files) to control who can use their EAs and for how long. This is impossible with raw MQ4 source code. I can help you troubleshoot by reviewing the
. In MetaTrader 4 (MT4), this is necessary because the platform can only execute the binary code found in .ex4 files, not the raw text in .mq4 files. Step-by-Step Compilation Guide The most reliable way to convert these files is using the MetaEditor tool, which comes bundled with your MT4 installation. Open MetaEditor
For developers selling trading robots, compiling to EX4 is the standard way to protect intellectual property. The buyer can use the EA but cannot see or steal the proprietary logic.
When providing an expert advisor to a client or selling it, the .ex4 file is the final product. 3. How to Convert MQ4 to EX4 (The Compilation Process)