Optimiser Results Not Matching "Run Single Test" Bug

 

Ran into something very strange. Issue:

If I run a single test on the same optimiser result 5 times, 2 out of the 5 times the result matches perfectly. The times it matches perfectly not a single error in the log. The other 3 times always the same error about INVALID_PRICE. Both optimiser and single test using "Every tick based on real ticks". How can one single run produce a perfect log and result, and the other times INVALID_PRICE issue. If it was a problem with my code, it surely would not produce a perfect log and match the optimiser result exactly multiple times.

I have read multiple forums here and implemented all suggested fixes into my code, including initialising global variables in the OnInit function. 

 
Alex Watkin:

Ran into something very strange. Issue:

If I run a single test on the same optimiser result 5 times, 2 out of the 5 times the result matches perfectly. The times it matches perfectly not a single error in the log. The other 3 times always the same error about INVALID_PRICE. Both optimiser and single test using "Every tick based on real ticks". How can one single run produce a perfect log and result, and the other times INVALID_PRICE issue. If it was a problem with my code, it surely would not produce a perfect log and match the optimiser result exactly multiple times.

I have read multiple forums here and implemented all suggested fixes into my code, including initialising global variables in the OnInit function. 

what type of optimization are you running ? 

are they all similar if you set the spread from floating to 1?

 
Lorentzos Roussos #:

what type of optimization are you running ? 

are they all similar if you set the spread from floating to 1?

Fast genetic based algorithm, have not tried on others.

If I set the spread to 1 instead of floating, wouldn't that make the test conditions different from the actual trading conditions during that period? Since the spread fluctuates in real-time, wouldn't a fixed spread potentially hide the issue rather than diagnose it
 
Alex Watkin #:

Fast genetic based algorithm, have not tried on others.

If I set the spread to 1 instead of floating, wouldn't that make the test conditions different from the actual trading conditions during that period? Since the spread fluctuates in real-time, wouldn't a fixed spread potentially hide the issue rather than diagnose it

it will identify if the issue is there tho

 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Alex Watkin:

I have read multiple forums here and implemented all suggested fixes into my code, including initialising global variables in the OnInit function. 

Not only global variables but all variables/objects/etc must be initialized.

If you observe sporadic results for the same external conditions/settings, there is a randomness in your code.