Hello fellow developers,
I'm writing a script, which in its functions, needs to read data from several indicators, nearly at the same time.During this development, I've encountered 2 problems:
The first being a Windows' window popping up telling me MT5 is using up too much memory (even though there are 12GB of RAM available and MT5 is only using ~750MB total), and that it will start closing other applications soon enough, if the memory consumption does not stop increasing.There are a few memory optimizations that i have done to make the code more memory efficient (such as freeing unsused buffers, and copying small amounts of data from the indicators' buffers at time, etc...). But, this is still not enough avoid the Windows warning.Is there a way to avoid this Windows "running out of memory" warning?
The second is that, when loading a high number of indicators, MT5 apparently is giving me and error and stopping the script. The error appears with different indicators, so it's not related to a single indicator.Also, with memory optimization, this error appears far before reaching the ~750MB "memory consumption" Windows warning, which makes me believe it's not related to memory consumption..Is there a limitation on the number of indicators which can be loaded onto a Symbol or accessed within a Script?
Thank you in advance,Diogo Seca
Is there a way to avoid this Windows "running out of memory" warning?
Is there a limitation on the number of indicators which can be loaded onto a Symbol or accessed within a Script?
I understand. But bear with me and suppose that I'm doing everything correctly, as far as efficiency goes, to achieve my goal.
I still need to know MQL5 and MT5 limitations, so I can at least redesign my solution, or abandon it altogether.For example, if you tell me that a symbol or a script can only run up to 64 indicators, then I'll know that for me to access 128 indicators is a task almost impossible to do, or at least, a very inefficient one.
Unfortunately, I cannot find any article, forum post or documentation on these 2 questions.
I still need to know MQL5 and MT5 limitations, so I can at least redesign my solution, or abandon it altogether.For example, if you tell me that a symbol or a script can only run up to 64 indicators, then I'll know that for me to access 128 symbols is almost a task impossible to do, or at least, a very inefficient one.
There is maybe some limitations but I am not aware of it.
If you provide some sample code I could check if you want.
Thank you Alain,
My current script source code is quite long and is comprised of several include files.
Therefor, I will create 2 friendly demonstrations for both problems, separately.
This script will demonstrate problem #2: Limitation on the amount of Indicators / Buffers that a script or terminal can hold, at a given time.
It will attempt to initialize a really big amount of indicators, in several symbols (you can select whether you want MarketWatch symbols or not)
At the moment, the limit number I'm getting seems to variate between 570 and 600 custom indicators.
Note: this script requires Examples\Custom Moving Average.ex5, which comes with the standard MT5 instalation.I've provided you with a copy of mine, in case you don't have it.
I couldn't reproduce that 713 : 7322 ratio or anything that resembles it:
Also, it seems that the error invalid EX5 file(12) only appears occasionally. Very strange..
I am using following code inside "i" loop :
When you got out of memory, strange things are happening ;-)
Indeed! Thank you Alain!
Using your code piece, the increase in indicator count was much slower, but the overall memory consumption was much higher (from under 800MB, now the memory consumption went up to 2.5GB!).This time, I did get a Windows warning of memory over-consumption.
Is there a limitation on the number of indicators which can be loaded onto a Symbol or accessed within a Script? Short answer: No.Long answer: Depends on how much available memory you have.
I'm now wondering whether my PC is making full use of my 16GB RAM, since it starts panicking at close to 8GB of mem.consumption. Perhaps the other 8GB are not being used..I'll update this post with more info if I find anything MT5\MQL5 related.