When an Expert Advisor (EA) refuses to load in MT4, the usual suspect is a pop-up about DLL imports. It's one of the most common "stuck" moments for traders, especially when moving to a new VPS or updating Windows. This guide provides a direct path to fix it, from the basic checkbox to a registry-level solution I've had to use on locked-down servers.
1. The Obvious (but often missed) Check: EA Properties
Most guides stop here, but it's the first gate. Right-click the EA in the Navigator window (Ctrl+N) and select "Properties" (or Modify). In the "Common" tab, you will find the "Allow DLL imports" checkbox. Ensure it is checked.
Many traders miss that this setting is EA-specific and not global. If you have multiple EAs, each one needs this permission enabled individually. If it’s checked and you still have the error, proceed.
2. The "Auto-Trading" Button and Terminal Settings
Sometimes the EA loads but the smiley face turns into a frown. This means the EA is attached but auto-trading is disabled.
3. The Core Fix: Understanding the MT4 Security Model
If the EA still throws a DLL error in the Experts tab (View -> Experts), you might be facing the "DLL imports are not allowed" error even with the box checked. This is where things get tricky.
MT4 has two layers of DLL security:
1. The User Layer (The checkbox we just clicked).
2. The System Layer (A global setting that overrides the checkbox).
If an EA uses complex DLLs (e.g., for database connections or advanced networking), MT4 might block it at the system level.
Fix: Go to Tools -> Options -> Expert Advisors. Look for the section "Allow DLL imports" and make sure "Allow imports of external DLLs" is checked. This is the master switch. If this is off, no EA will work, regardless of the EA properties.
4. The "File Access" Loop and Windows Permissions
I encountered a persistent error on a Windows Server 2022 VPS where the EA worked on the demo account but failed on the live account. The error log showed "File access error".
The EA was trying to write a log file to its own folder inside `MQL4\Files`. Even with DLLs allowed, MT4 restricts file operations to the `Files` folder and the `Experts` folder. However, Windows Administrator rights can interfere.
5. The Ultimate Fix: The Registry Edit (Dealing with Windows UC)
Here is the 独家视角 solution. On standard Windows installations, this usually isn't necessary, but on VPS instances with high security settings (like those using Windows Server Core or strict group policies), MT4 sometimes ignores the master switch.
MetaQuotes does not document this clearly, but MT4 reads a specific registry key to determine if it should allow DLLs via the system layer. I have resolved this by modifying the `HKEY_CURRENT_USER\Software\MetaQuotes\MetaTrader 4\Options` registry key.
While standard support won't tell you to do this, I have found it to be the only solution when MT4 settings are grayed out or reset after restart.
Warning: This forces the master switch on. Only use this if you are confident the EA source is safe.
6. The Dependency Check: Visual C++ Redistributable
Sometimes the EA loads, but nothing happens. No errors, no trades. This happens when the DLL loads but fails internally.
Most C++ based EAs require the Microsoft Visual C++ Redistributable. If it's missing, the DLL cannot initialize.
7. Final Verification: Check the Experts Tab
After applying all fixes, restart MT4. Attach the EA to a chart.
Reference:
*本文首发于FXEAR.com,原创内容,未经授权禁止转载。*