Enable DLL import in MetaTrader 4

This article will explain how to enable DLL import in MT4.

What's a DLL

DLL stands for dynamic link library. It's used extensively in Windows system. DLL is usually written in high level programming language such as C++.

How is DLL helpful in MT4

MetaTrader expert advisors and indicators are written in MQL, a proprietary programming language developed by MetaQuote company.

There are several aspects that DLL can benefit MQL programming.

  • DLL can be written in any programming language, such as C++, C#, Pascal, VB, etc. So more developers can create DLL than MQL program.
  • DLL can reuse billions of lines of existing code and make it easier to develop large project.
  • DLL usually has better performance than MQL.
  • MQL is limited. For example, we can't connect Sqlite database using MQL. There is no any limitation in DLL.
  • There are plenty of mature develop tools for DLL, such as Qt Creator, Microsoft Visual Studio, Eclipse, etc, while we only have MetaEditor to develop MQL.

Enable DLL globally

By default DLL is disabled in MQL program. We must enable it before we use any EA or indicators which uses DLL.

To enable DLL globally, in MetaTrader terminal, click menu Tools, then click Options, then select the tab Expert Advisors, as the image below

To enable DLL, check the box in the blue circle.

If DLL is enabled globally, all EA and indicators can use DLL.

Enable DLL for certain EA and indicator

DLL can be enabled for certain EA and indicator. After load the EA or indicator, in the configure window, select the tab Common, as the image below

To enable DLL, check the box in the blue circle.

If DLL is enabled, only the EA or indicator under configure can use DLL.

Is DLL dangerous?

Yes and No.

Unlike MQL that is running in a sand box which protected by MetaTrader, DLL can access all information and files on your computer. From this perspective we can say DLL is dangerous.

However, using DLL is nothing different than you download and run any software from the internet, include MetaTrader itself. Why do you dare to run MT4 terminal after you download from your broker website without any hesitation? Because your trust MetaQuote. So if you trust the vendor who provides you the EA/Indicator with DLL, DLL is safe to you.


bangkong, 2018/01/13 08:17

Thank you so much for sharing this great blog.Very inspiring and helpful too.Hope you continue to share more of your ideas.I will definitely love to read http://www.obatinfeksisalurankemih.com/

Jaime Rodriguez, 2016/06/04 16:32

Hi, do you know how to use python and/or R in mql4, thanks

Wang Qi, 2016/06/05 04:32

Hi, you can't use Python or R in MQL4 directly. The only way is to put your Python/R code to a DLL, expose the necessary functions, and call the functions in MQL4.

Daniel, 2016/12/04 18:17

Hello, If you're not afraid of .NET DLLs, there's a solution for making them play together: MQL4 and Python.

Enter your comment. Wiki syntax is allowed: