Home›Learn›Expert Advisors›What is a DLL in MT4?

What is a DLL in MT4?

A DLL lets an MT4 EA call external code for things MQL4 cannot do. That capability is useful and a real security risk. Here's both sides.

Expert Advisors5 minUpdated 14 Aug 2026
What is a DLL in MT4?

A DLL is a piece of compiled Windows code that an Expert Advisor can call to do things the MQL4 language cannot do on its own. That makes DLLs genuinely useful and genuinely dangerous, because a DLL runs with the full rights of your Windows account, outside the safety limits that normally contain an EA. If you run EAs, this is worth understanding before you tick the box that allows them.

What a DLL is

DLL stands for Dynamic Link Library — a compiled module of functions that Windows programs share. MQL4 can import functions from a DLL with the #import keyword, so the EA hands work to external code and gets a result back. The MQL sandbox that normally stops an EA reaching your files or the network does not apply to whatever happens inside the DLL.

Why EAs use them

Legitimate reasons are common:

  • Heavy maths or machine-learning models that would crawl in MQL.
  • Licensing checks that phone home to confirm you paid.
  • Trade copiers that move orders between two terminals on the same machine.
  • News feeds, web APIs or database connections MQL cannot open cleanly.

Plenty of respectable commercial EAs need a DLL and say so plainly. The capability itself is not the problem; the problem is granting it without knowing what the code will do with it.

The security risk

To use one, you must tick "Allow DLL imports" when you attach the EA, or globally in Options. Once ticked, the DLL can do anything your Windows user can: read and send your files, open network connections, log your keystrokes, download and run other software. An EA on its own is fairly contained. An EA plus a DLL you have not vetted is a program with full run of the machine your trading account lives on.

Never tick "Allow DLL imports" for an EA you cannot trace to a source you trust. The credentials to your account, and every file on the machine, sit inside the fence you are opening.

How to reduce the risk

  • Know who actually wrote the DLL, not only the vendor who sold the EA.
  • Run unknown EAs on a throwaway VPS, never the PC that holds your bank logins.
  • Be suspicious when a simple strategy insists on DLL access it has no reason to need.
  • Keep the DLL and its EA version-locked; a quiet swap of the DLL is a quiet swap of what runs.

A worked example

You buy a £90 "scalping robot" that only works with DLL imports enabled. The strategy is trivial and has no honest reason to reach outside MT4. A week later the investor password to your £8,000 account has been used from another country. Nothing in MT4 logged a break-in, because there was no break-in — you granted the access yourself when you ticked the box.

The Karnek note

Karnek never loads a DLL, never runs inside your terminal's trade permissions, and connects read-only. It can see and report your account's activity but cannot call external code, change a setting or place a trade — there is no box to tick that would let it.

See it in Karnek: monitor every EA live, with an alert the instant one stops.

More in Expert Advisors →

Written and reviewed by the Karnek Research team. Last updated August 2026.

Educational content only - not financial advice. Past performance does not predict future results. Trading carries significant risk.