Tester results are not matching optimization results

 

Hi,

I ran strategy optimization for my code. Picked a optimized results and ran the tester with those settings. Expert properties exactly match the optimization settings. But I am getting a different results for the same settings? I have seen this happen before? Is this a bug in Metatrader or is something wrong in my code? If there was anything wrong in my code both optimizer and tester should have shown the same result. I am confused. Could someone please help me?

 
If you do 3 times in a row, all with different results, well, it should be.
 
Are you using a fixed spread?

 

@deysmacro  :- I didnt get you. Are you saying try 3 times to get a different result?


@WHRoeder :- I am not using Spread. I am running on Mql4 metatrader so that doesnt have spread option.


I have attached the zip file. It has the video of the problem i am facing.




Files:
 
Try setting Tester Model: to Every tick and not Open prices only.
 

I have the same problem. No matter if tester model in mt4 is control points or every tick, trying to optimize any parameter the optimization results are absolutely different than in single tests. Single tests show good profit, optimization with the same settings show a loss. A search in the forum shows that problem occurs sometimes but I have no solution found. So mt4 optimization is not possible with any EA? Which properties does a EA need to be optimization -able in mt4?

 
Heiko Kendziorra #: I have the same problem. No matter if tester model in mt4 is control points or every tick, trying to optimize any parameter the optimization results are absolutely different than in single tests. Single tests show good profit, optimization with the same settings show a loss. A search in the forum shows that problem occurs sometimes but I have no solution found. So mt4 optimization is not possible with any EA? Which properties does a EA need to be optimization -able in mt4?

That is usually due to the EA code having bugs, especially in regards to the proper handling of the initialisation and de-initialisation process of the EA (e.g. proper initialisation and handling of global variables).

Another important point is to always use a fixed spread value and not use the "current" spread value, so that spread does not change between optimisation passes.

 

 
Fernando Carreiro #:

That is usually due to the EA code having bugs, especially in regards to the proper handling of the initialisation and de-initialisation process of the EA (e.g. proper initialisation and handling of global variables).

Another important point is to always use a fixed spread value and not use the "current" spread value, so that spread does not change between optimisation passes.

 

Thanks! I'll check initialisation and de-initialisation. I use fixed spread.

Reason: