You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The forum lost my posts
You are right with older build, all passes are fine, I checked.
I had found that the passes which provide wrong optimizations results, when run with "Single Test" have these errors :
All of these passes, and only these passes. The "good" passes doesn't have these errors.
Details of the log when this error occurs :
In older build, these errors happens too. But it doesn't affect the optimization.
That means that something changed in MT5 which makes these passes to fail when running as "optimization". I will report it to MetaQuotes attention.
Though by fixing these errors in your code you can probably workaround this issue.
It's seems that the problem comes from using un-initialized struct somewhere in mql5 source code, hence some garbage is interpreted (unintentionally and randomly). The fact that EA works with one build and fails with another, as well as during optimization vs single test - is a side effect of agent initialization: every agent is kept running between passes during optimization, so a memory heap could be probably inherited from one pass to another (in older builds) and this is why the error did not occur. Then something related to the heap was changed in newer builds, and more strict (or loose) behaviour of MT5 surfaces the bug in EA.
It's seems that the problem comes from using un-initialized struct somewhere in mql5 source code, hence some garbage is interpreted (unintentionally and randomly). The fact that EA works with one build and fails with another, as well as during optimization vs single test - is a side effect of agent initialization: every agent is kept running between passes during optimization, so a memory heap could be probably inherited from one pass to another (in older builds) and this is why the error did not occur. Then something related to the heap was changed in newer builds, and more strict (or loose) behaviour of MT5 surfaces the bug in EA.
That could explain why I never get such issue myself. Interesting.
Is it your own finding or it was discussed somewhere (link ?) ?
Thank you.
That could explain why I never get such issue myself. Interesting.
Is it your own finding or it was discussed somewhere (link ?) ?
Yes, I remember similar topics (on Russian forum) about sporadic results caused by uninitialized variables, but I can't provide a link right now.
It's seems that the problem comes from using un-initialized struct somewhere in mql5 source code, hence some garbage is interpreted (unintentionally and randomly). The fact that EA works with one build and fails with another, as well as during optimization vs single test - is a side effect of agent initialization: every agent is kept running between passes during optimization, so a memory heap could be probably inherited from one pass to another (in older builds) and this is why the error did not occur. Then something related to the heap was changed in newer builds, and more strict (or loose) behaviour of MT5 surfaces the bug in EA.
So based on this assumption, how can we avoid this error?
I don't think that applies to my case.
I have no structs in my code, and there's none in the sample EA I posted.
There are classes in a library that I use, MQL_Easy https://www.mql5.com/en/code/25104, but they all have proper constructors and initialization.
Also, I think that a randomly initialized variable would lead to different results when running the same single test multiple times, instead I always get the same results even on different MT5 instances and also on different computers, there's difference only between optimization and single tests.
I don't think that applies to my case.
I have no structs in my code, and there's none in the sample EA I posted.
There are classes in a library that I use, MQL_Easy https://www.mql5.com/en/code/25104, but they all have proper constructors and initialization.
Also, I think that a randomly initialized variable would lead to different results when running the same single test multiple times, instead I always get the same results even on different MT5 instances and also on different computers, there's difference only between optimization and single tests.
Uninitialized variable is as bad as unintialized struct. My wording was probably a bit free, but it's assumed that anything uninitialized (that should be) may mangle results unpredictably. Classes can also be flawed - and I'd not take it for granted that MQL Easy codes are rock solid. Did you proofread all of the stuff and are absolutely sure it's "proper" everywhere?
Randomly initilized variable is NOT uninitialized variable! ;-)
Any variable is allocated somewhere in memory. This place is usually the same for current session/program while environment is the same (as it is when you run the same tester agents pool with the same tested MQL program). No matter how many times you restart the process - if the environment does not change significantly (for example, you disabled part of the pool or, probably started another instance of MT5 - it's hard to say which factors can change the environment significantly) - all data sector of MQL program will be allocated on the same place. So if a variable is uninitialized, it will always get the same "garbage". Hence you'll always get the same incorrect result.
So based on this assumption, how can we avoid this error?
Check and fix MQL5 source codes.
and there's none in the sample EA I posted.
Hey, you did not provide source codes, so we can't check that "there's none" seriuos inside.
Uninitialized variable is as bad as unintialized struct. My wording was probably a bit free, but it's assumed that anything uninitialized (that should be) may mangle results unpredictably. Classes can also be flawed - and I'd not take it for granted that MQL Easy codes are rock solid. Did you proofread all of the stuff and are absolutely sure it's "proper" everywhere?
Randomly initilized variable is NOT uninitialized variable! ;-)
Any variable is allocated somewhere in memory. This place is usually the same for current session/program while environment is the same (as it is when you run the same tester agents pool with the same tested MQL program). No matter how many times you restart the process - if the environment does not change significantly (for example, you disabled part of the pool or, probably started another instance of MT5 - it's hard to say which factors can change the environment significantly) - all data sector of MQL program will be allocated on the same place. So if a variable is uninitialized, it will always get the same "garbage". Hence you'll always get the same incorrect result.
A variable that is not initialized gets a random value from memory, thus initialized with a random value (randomly initialized).
Such event, when run on different metatrader instances and even computers, would lead unavoidably to different results.
That doesn't happen, as I wrote already. The same setfile on different computers produces same exact results, that is very unlikely if a variable is initialized with random values, instead optimization results and single test run sometimes differ.
I agree that MQL_Easy might be flawed somewhere, although I checked all constructors and I've been using it for years now without problems.
That doesn't happen, as I wrote already. The same setfile on different computers produces same exact results, that is very unlikely if a variable is initialized with random values, instead optimization results and single test run sometimes differ.
Please, provide a source code to reproduce the problem.