Metatrader – Protection From MQL DecompilingOn July 27, 2023 by Shazaib Khatri75
A little bit of theory.
Expert advisors, indicators and scripts for the Metatrader system are created using the built-in MQL language. Then, the source text code MQ4 is compiled into executable binary code EX4. File with the EX4 extension contains program logic understandable to the Metatrader interpreter only. We will not see anything using ordinary text editor. This is convenient in exe decompiler if a programmer or trader provide their program for usage but doesn’t want the user to know the details of the sales strategy.
Unfortunately, there are methods of decompiling the EX4 files back to MQ4 which allow seeing the program logic. This is a big problem for those who want to keep the details of their trading strategy confidential.
Decompiling makes it pointless to create a business that is based on sales of expert advisors or providing them for usage. The existing companies suffer great losses.
There is an opinion that a good MQL programmer can write program in a way that would make it impossible to decompile. For example, by using licensing system. Well, unfortunately this is not the case. The strategy cannot be protected by means of MQL only.
Let us see several methods of protecting sales strategies. We will compare them and find out their pros and cons.
- Pure MQL
As we have already said, this method does not provide protection because an EX4 file can be easily decompiled. However, along with the cons, MQL programming has its pros which will be examined in comparison with the other methods.
Pros: simple structured language that is comprehensible by traders and not only by specialists. Lowest cost level as compared to other methods.
Cons: easily decompiled.
Special features: applicable for personal use or for refinement of the strategies logic.
MQL language has a very useful special feature. It allows the programs to link with the libraries (DLL) written in other programming languages. First of all, it essentially expands the possibilities and secondly, it allows moving MQL logic into the library which makes decompiling of an EX4 file useless.
DLL can also be decompiled however it is by no means easy and requires specific knowledge. When decompiled, the DLL code is translated into the Assembler (ASM) machine language. This procedure is called disassembly. Pay level of ASM specialists is very high, thus such expenses are unreasonable for hacking most projects.