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/.mq5directly; 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:
- 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
.dlllibraries. - 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.
- 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.
- Never Mix .ex4 and .ex5 Across Terminals: MT4 cannot read
.ex5and MT5 cannot read.ex4. Double-clicking an.ex4file outside MetaTrader will not install it properly—always paste it insideOpen 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/.ex5files to a specific MT4/MT5 account number or expiration date insideOnInit(). 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
.ex4files compiled over a decade ago can sometimes fail to initialize on current builds if no.mq4source 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 insideMQL4/IndicatorsorMQL5/Indicatorsunless embedded directly as a resource inside the EA binary.
ACTION CHECKLIST
- Verify file extension matches platform: Confirm you have an .ex4/.mq4 file for MT4 or an .ex5/.mq5 file for MT5.
- Place files in the exact MQL subfolder: Copy EAs into Experts, custom indicators into Indicators, and .set presets into Presets inside Open Data Folder.
- Inspect DLL and WebRequest permissions: Leave Allow DLL imports disabled unless verified from a trusted developer, and review any WebRequest domains.
- Test compiled behavior on Strategy Tester: Run a Strategy Tester simulation first to verify stop-loss placement, lot sizing, and order frequency.
- Validate on an isolated demo account: Monitor live demo execution in the Experts and Journal tabs before attaching the binary to live capital.