I still remember the exact moment. I'd spent the entire weekend backtesting a new Martingale EA, the backtest curves looked like a smooth 45-degree angle to the moon. I was ready to let it run on a live cent account. I dragged the EA onto the EURUSD chart, the little smiley face in the top right corner appeared, and then... nothing. No trades. I stared at the "Experts" tab in the Terminal window, and there it was: "DLL call is not allowed."
My first thought was just a quick fix. I right-clicked the EA in the Navigator, went to Properties, and ticked the box "Allow DLL imports." But the error didn't go away. Instead, I got a new one: "Error 126: The specified module could not be found." This is the moment most traders get stuck, and many give up. They think the EA is broken. But it's almost always an environmental issue with your Windows system. This guide is a record of how I systematically solved this problem, and how you can too, with a focus on the sneaky differences between Windows versions that no one talks about.
Step 1: The Obvious Check – EA Properties
Before you start blaming the EA code, let's confirm the basic settings. Open MetaTrader 4 and find your EA in the Navigator panel (Ctrl+N).
Right-click the EA's name.
Select "Properties" (or press Enter).
In the "Common" tab, make sure the following are checked:
"Allow DLL imports"
"Allow imports of external experts"
Crucially: If you are using a live account, check "Allow live trading" as well. This is often overlooked. Backtesting doesn't require this, but live trading does.
Here’s a quick screenshot for reference:
Screenshot description: MT4 Navigator panel -> Right-click on the Expert Advisor -> Properties -> Common tab. Highlight the three checkboxes for DLL imports, external imports, and live trading.
If the error persists, it's not a simple setting. We're moving to the deep dive.
Step 2: The "Error 126" – The Windows Dependency Trail
The EA I was using relied on a custom DLL file that connected to a SQLite database. When you get "Error 126," Windows is telling you that it found the DLL file, but it can't load it because a dependency of that DLL is missing. This is the #1 reason for EA load failures that nobody explains in the marketing materials.
Most custom DLLs are written in C++ and compiled using specific versions of the Microsoft Visual C++ Redistributable. Your EA might load perfectly on Windows 10 but fail on Windows 11, or vice versa, because of different runtime environments.
To diagnose this, you need to see what the EA is trying to load.
Navigate to your MT4 data folder. In MT4, go to
File -> Open Data Folder.Find the
Libraries folder. This is where your EA's custom DLLs should be placed. Make sure the DLL file is physically present in this folder.The First Fix: Install the Visual C++ Redistributable packages.
This is the most common fix for Error 126, yet many traders skip it. Go to the official Microsoft website and download the latest supported Visual C++ Redistributable packages. The official Microsoft documentation states that these runtimes are a prerequisite for many applications built with Visual Studio. (Reference: Microsoft Official Documentation, "Visual C++ Redistributable latest supported downloads").
You need both the x86 and x64 versions. Even if your Windows is 64-bit, MT4 is a 32-bit application, so the x86 package is essential.
After installation, restart your computer. This is critical because some environment variables are updated on reboot.
Step 3: The "Hidden" MetaQuotes Setting
Here's my exclusive perspective on this problem. Even after installing the VC++ packages, I was still getting an error. This is where I went beyond the standard tutorials.
There is a configuration file in your MT4 data folder called
MetaTrader.ini. This file stores various settings for the terminal, including some security policies that are not exposed in the standard GUI.Config folder.MetaTrader.ini file with a text editor (like Notepad++).[Experts].AllowDLLImports=1Why is this important? I discovered that sometimes, due to a previous crash or a recent update, this flag can be set to
0 even though the GUI says "Allow DLL imports" is checked. The GUI checkbox is just a user interface element, but the system reads the MetaTrader.ini file first at startup. By manually ensuring this flag is set to 1, you bypass any UI glitches.Reference: This is not in the official MQL4 documentation, but it is an advanced troubleshooting step used by developers that I've found to be a 100% effective fix for "stuck" EA loads.
Step 4: The Windows 10 vs. Windows 11 Difference
If you're still stuck, the problem is likely a specific missing file. I've encountered multiple scenarios where the error message is vague. To get a clear picture, we need to use a tool called Dependency Walker (or a modern alternative like
dumpbin from Visual Studio). However, for most traders, a simpler approach is to check the system logs.Open Windows Event Viewer (type
Event Viewer in the Start menu).Go to
Windows Logs -> Application.Look for Error events from the source
Application Error or SideBySide.These logs will often pinpoint the exact missing DLL file or the specific runtime version required.
My experience with Windows version differences:
ucrtbase.dll (Universal C Runtime). If you get an error related to ucrtbase.dll, you need to install the Windows 11 SDK or ensure you have the latest Windows updates installed. This is a Microsoft requirement that comes with Windows 11's security model. (Reference: Microsoft Documentation on Universal C Runtime).If you are on Windows 11 and getting a SideBySide error, the fix is often to install the latest "Microsoft Visual Studio 2015-2022 Redistributable" and update Windows to the latest build.
Step 5: The Clean Reinstall – Last Resort
If all else fails, a clean reinstall of MT4 and the EA is necessary. But don't just delete the folder.
%APPDATA%\MetaQuotes\Terminal folder and delete the entire folder associated with your broker. <strong>Important</strong>: Back up your profiles and templates first.C:\MT4 instead of C:\Program Files). The "Program Files" folder has extra security restrictions that can interfere with DLLs, even if you run as administrator.Step 6: The EA Code Check
Sometimes, the problem isn't the environment; it's a tiny typo in the EA code itself. If you have access to the source code (MQ4 or MQ5 file), you need to check the
#import directives.The
#import statement tells the compiler which DLL and function to use. A common mistake is not matching the function name or the calling convention.``
c++
#import "MyCustomLib.dll"
int MyFunction(string param);
#import
`
If the DLL is named incorrectly, or the function signature is wrong, the EA will compile fine but fail to run. This is where the MQL4/MQL5 documentation is your best friend. It clearly outlines the import rules and the types that can be passed to a DLL. (Reference: docs.mql4.com, "Importing functions").
Final Check: You've allowed DLL imports in the GUI, verified the MetaTrader.ini file, installed all VC++ runtimes, and confirmed the DLL is in the Libraries folder. If it still doesn't work, open the source code, comment out the #import` lines, and re-add them one by one to isolate which call is failing.The "Error 126" is a pain, but it's almost always a solvable environmental issue. It's rarely the EA itself. Most of the time, it's just a missing piece of software that Windows needs to run the EA's code. By following these steps, you should be able to get any EA running, regardless of whether you're on Windows 10 or Windows 11.
Reference:
本文首发于FXEAR.com,原创内容,未经授权禁止转载。