
How to Allow DLL Imports in MT5 and Fix "DLL Loading Is Not Allowed"
To allow DLL imports in MT5, you need to switch on permission in two places, and missing either one produces errors such as "DLL loading is not allowed" or "cannot load" followed by the library's name. Some Expert Advisors rely on a DLL, which is a Windows library that gives the EA abilities MQL5 does not have on its own. MetaTrader 5 blocks DLLs by default, so until you allow them, an EA that depends on one either refuses to start or stops the first time it tries to use the library.
The fix takes about a minute once you know where the two settings are. This guide shows you both, then explains what to check when the DLL file itself is the problem and how to allow DLLs only for the EAs you trust.
Why an MT5 EA needs a DLL#
MQL5, the language EAs are written in, only has limited access to your computer, which is a deliberate safety choice by MetaQuotes. A DLL lets an EA go beyond those limits, for example to keep a network connection open so that it can receive messages the moment they are sent, which MQL5's built-in WebRequest cannot do because it only sends a request and waits for a single reply.
The PineHook EA is an example. It uses PineHook.dll to hold a live connection that delivers each TradingView alert to your terminal as soon as it arrives, instead of checking for new alerts every few seconds, which is why it cannot connect until DLL imports are allowed.
How to allow DLL imports in MT5#
MT5 checks DLL permission at two levels, and both of them have to allow it.
The terminal default. Open Tools → Options, select the Experts tab, which older builds label Expert Advisors, and tick Allow DLL imports. MT5 labels it as potentially dangerous and to be enabled only for trusted applications, and it becomes the default for every EA you attach from now on.
Tools → Options → Experts in MetaTrader 5, with Allow DLL imports ticked as the default for newly attached EAs.The EA itself. Open the attached EA's properties from the chart, for example by pressing F7, go to the Dependencies tab and tick Allow DLL imports. This is the permission the running EA actually uses, and an EA attached before you changed the terminal default keeps its old value until you change it here. The same tab lists every library the EA imports, so you can see exactly what you are approving.
Properties of the PineHook EA running on a EURUSD chart, opened with F7. Allow DLL imports is ticked, and PineHook.dll appears in the list of imported libraries.Click OK and the EA reinitialises with the new permission. If it still reports the same message, remove it from the chart and attach it again so that it loads with the current settings.
Allow DLLs per EA rather than for everything#
Ticking the terminal-wide option lets every EA you attach call any DLL it ships with, so a safer habit is to leave the terminal default off and allow DLLs on the Dependencies tab only for the EAs you trust.
When MT5 still cannot load the DLL#
If DLL imports are allowed and MT5 still cannot load the library, the file is missing, in the wrong place, or unable to run, and the message in the log tells you which.
"cannot load ... [126]"#
126 is a Windows error meaning the module could not be found, which most often happens because the DLL is not in the folder MT5 looks in or has been renamed. Open File → Open Data Folder and check that the file sits in MQL5\Libraries with exactly the name the EA expects. A copy downloaded twice can come out as PineHook (1).dll, which the EA will never find. The same code can also appear when the DLL depends on another component that is not installed, such as a Microsoft Visual C++ runtime, and the EA's documentation should list any such requirement.
32-bit and 64-bit DLLs#
MT5 is a 64-bit application and can only load 64-bit DLLs, so a library built for 32-bit Windows, or one written for MT4, will not load in MT5 whatever the settings say.
Antivirus quarantine#
Security software sometimes removes or blocks an unfamiliar DLL right after it is downloaded or extracted, so if the file disappears from MQL5\Libraries, check your antivirus history before copying it in again.
"unresolved import function call"#
This means the EA reached a call into a library that was never loaded, usually as a consequence of one of the problems above, so fix the load error that appears before it in the log and this one goes away with it.
Why MQL5 VPS cannot run DLL-based EAs#
MetaQuotes' built-in virtual hosting does not allow DLL calls at all. Its hosting rules state that a program calling a DLL function on a virtual terminal is stopped with a critical error, so no setting can make a DLL-based EA run there. Use a regular Windows VPS instead, where MT5 runs exactly as it does on your own computer, or a computer that stays on.
How PineHook tells you when the DLL is the problem#
PineHook ships its DLL in the same bundle as the EA, so installing it means copying two files: PineHook.dll into MQL5\Libraries and the EA into MQL5\Experts, as Connect MetaTrader 5 shows step by step. If the EA reports WebSocket connection failed, the connection issues guide walks through the checks in order, starting with the two DLL settings above, then the exact file name, and finally outbound access on port 443. That order means you never have to work out from a Windows error code which of them is at fault.
Once the EA is connected, Signal Logs → Test EA Connection confirms the full route to your license without placing a trade, which tells you the DLL is loaded and working before your first live alert. Allowing DLLs only lets the EA connect, though, and placing trades is controlled separately by Algo Trading, which our guide to an MT5 EA that is not trading explains. You can create a PineHook account without payment details to download the bundle and try the setup on a demo account.
FAQ#
Is it safe to allow DLL imports in MT5?
A DLL runs with the same access to your computer as MetaTrader itself, so allow it only for EAs from a source you trust, and per EA rather than terminal-wide, which is the same judgement you would apply to installing any other Windows program.
Do I need to restart MT5 after allowing DLL imports?
Usually not. Changing the EA's Dependencies tab reinitialises it with the new permission. If the message persists, reattach the EA, and restart MT5 if a newly copied DLL is still not found.
Does MT5 on Mac support DLL-based EAs?
MT5 on macOS runs inside a compatibility layer, and support for third-party Windows DLLs in that setup varies, so check with the EA's developer before relying on it, or run MT5 on a Windows VPS instead.
Related guides#
- MT5 EA not trading
- What happens to alerts when the MT5 EA disconnects
- Connect MetaTrader 5
- Connection issues
MetaTrader is a trademark of MetaQuotes, and PineHook is an independent product that is not affiliated with, endorsed by, or sponsored by MetaQuotes. Leveraged trading carries a high risk of loss, so test any automated setup on a demo account before you trade it live.
