Running compiled EX4 files in MetaTrader 4 forms the backbone of automated retail currency trading. While source code files (.mq4) allow developers to write and alter trading logic using MetaEditor, finished expert advisors, custom indicators, and scripts are distributed as binary EX4 files to protect proprietary code. Getting these compiled binaries to execute properly on live or demo charts requires precise directory placement, correct terminal settings, and careful handling of security permissions.
Understanding how the MetaTrader 4 architecture handles these compiled files prevents common execution failures, such as blank charts, unresponsive trading robots, or missing indicator lines. This manual outlines the exact mechanical pipeline required to install, configure, and run EX4 files in MetaTrader 4 for stable, precise strategy execution.
Locating and Preparing the MT4 Directory Structure
MetaTrader 4 relies on a strict directory hierarchy to identify and load custom programs. Modern builds of the platform use a centralized data folder architecture rather than relying exclusively on the root installation directory inside Program Files. This change prevents permission blocks when the platform attempts to write logs or read configuration files.
To access the active directory, launch your terminal, navigate to the top menu, select File, and click Open Data Folder. Inside this root directory, open the MQL4 folder. This container holds separate subdirectories categorized by program type:
- Experts: Dedicated destination for automated trading robots and Expert Advisors (EAs).
- Indicators: Designated path for custom technical indicators and visual analysis tools.
- Scripts: Storage location for one-off automated functions that execute once and terminate.
- Libraries: Storage for shared function routines compiled as binary components.
Copy your target binary file from your local downloads directory. Paste it directly into the matching subfolder. For automated trading algorithms, paste the file into MQL4\Experts. For analytical overlays, place it inside MQL4\Indicators. Avoid nesting files inside custom sub-directories within these folders unless the developer explicitly mandates a sub-path, because the platform's navigation tree only scans one level deep by default.
Refreshing the Terminal and Navigator Window
Once you place the file into the appropriate directory, the platform needs to register the asset. Simply dropping a file into the folder while the terminal remains open will not automatically populate the user interface.
Close and completely restart the MetaTrader 4 application. This forces the terminal process to reload its asset cache and parse the updated directory contents. After reopening the platform, open the Navigator panel by pressing Ctrl+N or selecting View followed by Navigator from the main toolbar.
Expand the Expert Advisors or Custom Indicators tree inside the Navigator window. Your newly added file should appear in the list. If the file fails to display, verify that the extension is strictly .ex4 and that you placed it in the exact matching category folder rather than the root directory.
Attaching and Configuring Strategy Execution Settings
With the binary recognized by the Navigator panel, you can attach it to a live price chart. Open a chart window for the financial instrument and timeframe you intend to trade. Drag the strategy name from the Navigator panel directly onto the active chart surface, or right-click the name and select Attach to a chart.
A dedicated configuration window will pop up immediately, displaying several tabs:
- Inputs Tab: Lists external configuration variables defined by the developer, such as lot sizes, stop-loss thresholds, take-profit levels, and trend filter periods. Adjust these values to match your risk parameters before execution.
- Common Tab: Contains security permissions that dictate how the strategy interacts with your broker's server.
To ensure uninterrupted strategy execution, you must grant specific permissions under the Common tab. Check the box labeled Allow live trading. If your strategy requires sending web requests to external endpoints for data feeds or licensing checks, check the box labeled Allow DLL imports.
Additionally, navigate to the global terminal settings by pressing Ctrl+O or selecting Tools > Options, then open the Expert Advisors tab. Verify that Enable Expert Advisors is checked. Without this global switch active, the platform blocks all automated order generation regardless of individual chart settings.
Validating Execution Status and Troubleshooting
After completing the setup configuration and clicking OK, look at the top-right corner of the price chart. A successful execution state displays a small smiling face icon next to the name of the Expert Advisor.
If you see a frowning face or a small red "X" symbol, the strategy is blocked from executing trades. Address these common status errors using these checks:
- Frowning Face: Indicates that global automated trading is disabled or the individual chart lacks live trading permissions. Re-check the global Options menu and the chart's Common tab settings.
- Missing Trades: Verify that the main AutoTrading button on the primary toolbar is pressed down and highlighted in green. If this master toggle is turned off, all automated execution stops instantly, even if individual strategies display a smiling face.
- Journal Errors: Open the Terminal toolbox at the bottom of the screen (
Ctrl+T) and select the Journal tab. Read the real-time log messages for specific error codes, such asexpert stoppedortrade context busy, which point to broker-side restrictions or coding conflicts.
For further reading on platform architecture and official specifications, consult the MetaQuotes MQL4 Documentation. You can also review general platform operations through official brokerage guides like the Skilling MT4 Installation Support.
Frequently Asked Questions
Can I edit or view the source code of an EX4 file?
No. An EX4 file is a compiled binary executable. It hides the original MQL4 source code to protect intellectual property, meaning you cannot open or modify it inside MetaEditor. You need the original .mq4 source file to make code changes.
Why does my Expert Advisor stop running when I switch timeframes?
Switching the chart timeframe or changing the financial instrument closes the current chart session and opens a fresh one, which automatically unloads any attached Expert Advisors. You must re-attach the strategy to the new chart.
What causes a "DLL imports allowed" warning?
Many advanced commercial strategies require external dynamic link libraries (.dll files) to handle license verification or advanced mathematical calculations. If the strategy's code relies on external DLL calls, you must explicitly check the Allow DLL imports box during the chart attachment phase, or the terminal will block execution for security reasons.
Can I run multiple Expert Advisors on the same chart?
MetaTrader 4 permits running a maximum of one Expert Advisor and one script per chart, alongside an unlimited number of technical indicators. To run multiple trading algorithms simultaneously, open separate chart windows for each strategy or instrument.