Algorithmic and Mechanical Forex Strategies | OneStepRemoved

  • Articles
  • Sophisticated Web Sites
  • Automated Trading
  • Testimonials
  • Contact

When does an Expert Advisor need a dll?

December 19, 2011 by Shaun Overton 20 Comments

Most Expert Advisors do not need a DLL. Although programming in MQL is fairly limiting, it suffices for 99% of expert advisors. DLL programming for MetaTrader is only appropriate whenever MQL does not offer a capability that the EA needs.

What is a DLL?

DLL stands for dynamic link library, which is not the least bit helpful in understanding what it does. Conceptualize a toolbox full of tools. The DLL itself is the toolbox. The “stuff” in the DLL is the tools that the expert advisor or indicator uses to make decisions. The MQL simply decides which tool to use at which time.

DLLs only work in MetaTrader if

MetaTrader allows Expert Advisors the ability to control whether or not MQL may use a DLL. This option is the first one appearing in the screenshot above. The indented option to “confirm DLL function calls” is a subset of this option. Whenever MT4 wants to use a DLL, it will prompt the user with a yes/no message box every single time that the DLL is used. It’s very annoying. MetaTrader would be better off without this option as it confuses most users.

When to program a MetaTrader DLL

Speed

I often encounter the need for a DLL whenever I plan to do mathematically intensive programming. MQL runs extraordinarily slowly for a programming language. Whenever an EA wants to process several million calcualtions, it tends to freeze. MetaTrader suspects that it fell into an infinite loop and chokes.

Moving those calculations into a DLL passes that responsibility for calculating the numbers to a more powerful language. MetaTrader only likes C/C++ or Delphi, which are referred to as higher level. The MQL programmer can control the physical hardware in order to optimize performance if it’s required. That would ususally be overkill. A generic dll program written C will run many, many times faster than the same code in MQL. We only program DLLs at OneStepRemoved in C or C++ (read as C plus plus).

Sell products in MetaTrader

MQL is a programming language designed entirely for trading. Anything that extends outside the sphere of trading, such as connecting to a database or reading information from a server, is not supported.

A business that wants to sell an Expert Advisor absolutely needs a DLL. The higher level languages easily support web operations that can authenticate who is and is not allowed to use a file.

More importantly, high level languages offer dramatically stronger encryption options. Decompiling an MQL file, which means breaking it open to steal the contents, only costs about $10-15 if you do enough Google searches. Cracking a DLL file takes much more work. Even an unencrypted file might take a programmer a few work full works days to open. Cracking an encrypted DLL could take months if the crack to the encryption is not known. Although anything that can be encrypted can theoretically be deencrypted, it becomes a matter of scale and resources. Would cracking your file warrant someone’s full time employment for several months? The answer is no for all but the most sensitive of material.

Bridge multiple instances of MetaTrader

Occasionally, traders design Expert Advisors that need to receive information from multiple brokers at the same time. Broker arbitrage and trade copiers fall firmly into this category. In the case of the trade copier, the MT4 account that wants to copy another account needs to know what is happening. The DLL stands in the middle between them as a path to pass information back and forth.

Many other problems are most appropriately solved with a DLL. If you aren’t sure if it makes sense for your situation, then please contact me.

Filed Under: MetaTrader Tips, Uncategorized Tagged With: bridge, dll, sell EA, speed

Comments

  1. paolo sioli says

    December 17, 2013 at 09:25

    ciao
    i’m interested in your dll programming capabilities
    i absolutely need multithread on mt4 backtest optimization, with the possibility to use all cpu cores of a pc, and all cpu cores in my lan. i know it should be possible using dll programming on mt4. can you help me?
    thanks

    Reply
    • Shaun Overton says

      December 17, 2013 at 09:32

      Hi Paolo,

      MT4 is limited to a single core – there’s no way to multithread the DLL to speed up your backtests. I wish I could help, but it’s a design flaw in MetaTrader 4.

      Reply
      • Reynard says

        December 14, 2015 at 20:49

        Hi Shaun,

        I have got an indicator that i want to sell online.
        How do i use DLL or anything else that prevents people from redistributing my indicator once they purchase my indicator online?

        Thank you,
        Reynard

        Reply
        • Shaun Overton says

          December 18, 2015 at 12:18

          Hi Reynard,

          Please contact me directly. I have a solution named Trader Lockdown that does exactly that.

          –Shaun

          Reply
  2. Florin says

    November 8, 2014 at 01:29

    Thank you for this professional article.

    Reply
  3. Evans Njuguna says

    December 8, 2016 at 08:42

    Hi Shaun,,,
    Great article and your expertise on metatrader-dll is highly appreciated. I need your help in converting some of the code in my EA into dll,,,,for speed/efficiency purposes and also for security. Kindly assist.
    Thanks.
    Njuguna.

    Reply
    • Shaun Overton says

      December 8, 2016 at 09:28

      Hi Njuguna,

      Please email your EA to info@onestepremoved.com in order to receive an estimate.

      –Shaun

      Reply
  4. Johnson says

    June 28, 2017 at 17:53

    So is there a way to have a backtest on a ea you want to test on strategy test That you say “alllow DLL imports “I’m really want to test on my ea on strategy test and is there a way to enable it to run on strategy test?

    Reply
    • Shaun Overton says

      July 24, 2017 at 15:42

      The EA can refuse to run all backtests regardless of whether a DLL is involved or not.

      Reply
  5. wakup309 says

    February 18, 2018 at 01:18

    Hi Shaun,

    How to Receive mt4 data from proxy server between client and server, can you guide me to general steps , thank you .

    Reply
    • Shaun Overton says

      February 26, 2018 at 16:27

      That’s not something that I expect to cover soon.

      Reply
  6. Dennis Lai says

    February 24, 2018 at 10:35

    Hi Shaun,

    thank you for your great sharing above
    I have a question, if I’m going to build a EA that wish to check equity or balance if down to certain level, then :
    1) close all running and pending orders (even open by other EAs)
    2) stop new others from any other EAs

    believe (1) no need DLL, while is that needs DLL coding?

    thx.
    Dennis

    Reply
    • Shaun Overton says

      February 26, 2018 at 16:26

      DLL is completely unnecessary for those tasks.

      Reply
  7. Kosta says

    March 3, 2018 at 14:57

    Hi. I am on the first time on your site. My English is not very well. Sorry.
    I have one question How does any program Expert Advisor reads the price of EURUSD (or GBPUSD ,..) from editor of MT4?
    Thank you. Kosta.

    Reply
    • Shaun Overton says

      April 10, 2018 at 05:42

      Use the function MarketInfo()

      Reply
  8. Khaled says

    June 10, 2018 at 07:45

    Need tour help
    I have an EA that i want to sell
    But its need to call an indicator ans a dll file
    Aldo i have problèmes of checking trade volume before sends orders
    Help me please

    Reply
    • Shaun Overton says

      June 18, 2018 at 10:55

      Hi Khaled,

      Please email info@onestepremoved.com and ask about Trader Lockdown.

      –Shaun

      Reply
  9. Dee says

    June 17, 2018 at 18:45

    Can someone access all the files on my system through enabling DLL. Or the programmer only have access to my platform

    Reply
    • Shaun Overton says

      June 18, 2018 at 10:53

      Theoretically they could, but your antivirus would likely detect that kind of attempt.

      Reply

Trackbacks

  1. Decompiling ex4 | One Step Removed says:
    January 12, 2012 at 13:44

    […] you sell expert advisors or sell custom indicators, the most appropriate approach is to program the MetaTrader file in a DLL. It’s even better to encrypt the […]

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

FREE trading strategies by email

Trending

Sorry. No data so far.

Archives

  • Dominari
  • How does the forex market work?
  • Indicators
  • MetaTrader Tips
  • MQL (for nerds)
  • NinjaTrader Tips
  • Pilum
  • QB Pro
  • Stop losing money
  • Test your concepts historically
  • Trading strategy ideas
  • Uncategorized
  • What's happening in the current markets?

Translation


Free Trading Strategies

Privacy PolicyRisk Disclosure

Copyright © 2023 OneStepRemoved.com, Inc. All Rights Reserved.