Technical & Risk GuidesIntermediate9 min read

EX4 & EX5 FILES EXPLAINED: HOW COMPILED METATRADER ROBOTS WORK

Understand .ex4 and .ex5 compiled files vs .mq4/.mq5 source code and .set presets, why decompilation fails on modern builds, and how to verify compiled EAs safely.

By YoForexEA Research Desk

Quick Summary

An .ex4 or .ex5 file is a compiled binary executable created by MetaEditor from .mq4 or .mq5 source code so MetaTrader 4 or 5 can run an Expert Advisor or indicator rapidly. Modern .ex4 (Build 600+) and .ex5 binaries cannot be cleanly reverse-engineered into safe source code; always verify DLL/WebRequest permissions and test on demo first.

What Are .EX4 and .EX5 Files?

When you download a MetaTrader trading robot or custom indicator, you typically receive an .ex4 file (for MetaTrader 4) or an .ex5 file (for MetaTrader 5). These are compiled binary programs produced when a developer compiles human-readable MQL4 (.mq4) or MQL5 (.mq5) source code inside MetaEditor.

Separating source code from compiled binaries serves two purposes: MetaTrader executes compiled machine/bytecode faster during live ticks and Strategy Tester passes, and developers can distribute working bots without exposing proprietary strategy code.

Complete MetaTrader File Types Reference

Extension Platform Role & Editability Correct Data Folder Path
.ex4 MT4 only Compiled executable EA, indicator, or script (not directly human-editable) MQL4/Experts (or Indicators / Scripts)
.mq4 MT4 only Plain-text MQL4 source code editable in MetaEditor; compiles into .ex4 MQL4/Experts (or Indicators / Scripts)
.ex5 MT5 only Compiled executable MT5 program; incompatible with MT4 MQL5/Experts (or Indicators / Scripts)
.mq5 MT5 only Plain-text MQL5 source code editable in MetaEditor; compiles into .ex5 MQL5/Experts (or Indicators / Scripts)
.mqh MT4 / MT5 Reusable include library file imported by .mq4/.mq5 source during compilation MQL4/Include or MQL5/Include
.set MT4 / MT5 Saved configuration preset storing EA input values; portable text/INI format MQL4/Presets or MQL5/Presets

Why Modern .EX4 and .EX5 Files Cannot Be Cleanly Decompiled

Years ago, pre-2014 MT4 builds compiled simple bytecode that utilities could partially reconstruct. Following MT4 Build 600+ and across the entire MetaTrader 5 architecture, MetaQuotes replaced legacy compilers with encrypted native-level compilation and symbol stripping.

Claiming to cleanly convert modern ex4 to mq4 or ex5 to mq5 is technically unrealistic and carries serious risks:

  • Broken Logic & Missing Names: Even partial disassembly loses meaningful variable names, comments, include structures, and control flow, making reconstructed output unreliable for live financial execution.
  • Malware & Scam Risk: Websites advertising "free .ex4/.ex5 decompilers" or "unlimited cracked EAs" frequently bundle credential stealers, clipboard hijackers, or hidden account-draining scripts.
  • Intellectual Property & Integrity: Legitimate open-source tools distribute .mq4/.mq5 directly; compiled commercial binaries remain encrypted by design.

Security Verification Before Running Any Compiled EA

Because you cannot read the source code inside an .ex4 or .ex5 file, follow strict sandbox hygiene before attaching any third-party binary to a live trading account:

  1. Keep DLL Imports Off by Default: Pure MQL4/MQL5 binaries operate inside MetaTrader's sandbox and cannot touch external Windows files unless you enable Allow DLL imports. Avoid third-party bots that demand undocumented .dll libraries.
  2. Inspect Requested WebRequest URLs: Never blindly whitelist unknown URLs in Terminal Options. If an EA posts an Experts tab error requesting a specific domain, confirm who operates that endpoint.
  3. Check Behavior in Strategy Tester & Demo Terminal: Run the binary in Strategy Tester and on a throwaway demo account while watching the Trade, History, and Experts tabs—confirming it places realistic stop-losses and does not open hidden correlated martingale baskets.
  4. Never Mix .ex4 and .ex5 Across Terminals: MT4 cannot read .ex5 and MT5 cannot read .ex4. Double-clicking an .ex4 file outside MetaTrader will not install it properly—always paste it inside Open Data Folder > MQL4 > Experts.

Managing .Set Presets, Licensing & Terminal Build Updates

While .ex4 and .ex5 binaries hold the trading algorithm, .set preset files store only your external input parameters in plain readable text. Saving separate .set files per symbol and broker (for example, Scalper_XAUUSD_ECN_05pct.set) lets you migrate settings cleanly across terminals or VPS upgrades without retyping Magic Numbers, GMT offsets, or spread thresholds by hand.

Keep two operational realities in mind when working with compiled binaries:

  • Account-Locked or Time-Limited Binaries: Commercial developers frequently bind compiled .ex4/.ex5 files to a specific MT4/MT5 account number or expiration date inside OnInit(). If a licensed binary immediately unloads with an authorization error, check the Experts tab for account-number mismatch notes.
  • Platform Build Compatibility: MetaQuotes periodically updates MT4 and MT5 terminal builds. Very old .ex4 files compiled over a decade ago can sometimes fail to initialize on current builds if no .mq4 source is available for recompilation in modern MetaEditor.
  • Custom Indicator Dependencies: A compiled EA that calls a custom indicator via iCustom() requires that exact companion indicator binary inside MQL4/Indicators or MQL5/Indicators unless embedded directly as a resource inside the EA binary.

ACTION CHECKLIST

  1. Verify file extension matches platform: Confirm you have an .ex4/.mq4 file for MT4 or an .ex5/.mq5 file for MT5.
  2. Place files in the exact MQL subfolder: Copy EAs into Experts, custom indicators into Indicators, and .set presets into Presets inside Open Data Folder.
  3. Inspect DLL and WebRequest permissions: Leave Allow DLL imports disabled unless verified from a trusted developer, and review any WebRequest domains.
  4. Test compiled behavior on Strategy Tester: Run a Strategy Tester simulation first to verify stop-loss placement, lot sizing, and order frequency.
  5. Validate on an isolated demo account: Monitor live demo execution in the Experts and Journal tabs before attaching the binary to live capital.

FREQUENTLY ASKED QUESTIONS

How do I open or view an .ex4 file on Windows?

You do not open .ex4 files directly in Windows or Notepad—doing so shows unreadable binary data. Install the file by pasting it into MT4's File > Open Data Folder > MQL4 > Experts folder and attaching it inside MetaTrader 4.

Can I convert an .ex4 file to .ex5 to use it on MetaTrader 5?

There is no automated converter from .ex4 to .ex5 because MT4 and MT5 use incompatible compiled architectures. You need either an official MT5 .ex5 release from the author or the original .mq4 source rewritten in MQL5.

Is it safe to run an .ex4 or .ex5 EA if I keep DLL imports disabled?

Disabling Allow DLL imports keeps the EA inside MetaTrader's sandbox so it cannot run arbitrary Windows executables. You still must test it on a demo account to ensure its trading strategy does not over-leverage or trade without stops.

What is a .set file and do I need one alongside an .ex4 or .ex5?

A .set file stores preset input parameters (such as lot risk, trading hours, and symbol settings). The EA runs without it using default values, but loading a verified .set file saves manual input configuration.

EXPLORE RELATED EA HUBS

MT4 Expert Advisors →MT5 Expert Advisors →MT4 Indicators →

CONTINUE READING

EXPLORE VERIFIED EXPERT ADVISORS

Browse MT4 and MT5 bots, indicators, and setup resources across YoForexEA.

Browse EAsAll 18 Guides