.ex4 libraries do not behave like DLLs. It will load a new copy and allocate a new heap for every EA, even multiple copies if you have circular dependencies. For most purposes it will behave as if the code was statically compiled into the EA. This is the reason I don't use them at all, they behave not as one would expect from a *shared* library at all and so they don't give me any benefit over putting the functions directly into an include file and compile one statically linked binary.
I have break them down into ex4 libraries because I already have more than 100 'include' source code files, and compiler refuses to compile around more than 100 include files.
You mean that it is thread-safe to use ex4 imports, and that the mql4-unique 'static' inner variable of a method will behave just like as if it is 'statically compiled' (meaning, users of same imported ex4, wont share the same memory values with my EA, for the static inner method variable). Is that correct?
Yes. This is what I read out of the manual: https://docs.mql4.com/runtime/imports (I did not make intensive tests, instead after reading this I immediately decided to never ever use .ex4 libraries to keep any potential trouble away if they are implemented in such a half baked way.)
PS:
how do you arrive at more than 100 includes for one EA? You must truly have a *huge* code repository. I have basically one include with ~30 functions in it for most of the everyday work (failsafe order sending and manipulation (trailstop, close all, scale in/out/reverse, etc.), some chart objects manipulation and some other helper functions for everyday use) and a handful of includes for very special things that I don't need in every EA. But I cannot imagine any scenario that would require me to include 100 different files.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
First of all, are all mql4 rules respected when calling 'imported ex4' methods? What I mean is, imported ex4 methods can also have 'static method variables' and that these 'static method variables' will behave as per mql4 rules?
Second, when two EAs import the same ex4 (assume that runtime loader loads exactly same ex4 files), will the 'common' method which happens to have a 'static method variable', be serving the same single 'static method variable' to both EAs? Or will the 2 EAs will possibly load the same ex4, e.g. from memory, but still have their OWN workspace, and therefore not 'share' the same single 'static method variable' value?
And thirdly, and most importantly, will 2 EAs calling the same 'imported ex4' method be up to a possible thread 'mixup' or conflict? What I mean is, the common software development thing on 2 clients entering the method at almost same time and eating or processing same time inside the method, cooking up trouble and garbage.