Optimization results inconsistent with backtest of strategy tester

To add comments, please log in or register
TobiasBecker
78
TobiasBecker  

Hello,

I just optimized an EA of mine using the MQL Cloud Network. When I backtest the EA using those optimized parameters, the backtest results differ drastically from those reported by the optimizer.

Example:
In the optimization results, a big profit is reported for a given set of parameters, but when I use those same parameters as inputs of a backtest in the strategy tester, a loss occurs.

Did this ever happen to anyone of you and if so, how did you fix it? Do you know what could cause such issues?

Best regards,

Tobias

Fernando Carreiro
4457
Fernando Carreiro  
TobiasBecker: I just optimized an EA of mine using the MQL Cloud Network. When I backtest the EA using those optimized parameters, the backtest results differ drastically from those reported by the optimizer.

Example:
In the optimization results, a big profit is reported for a given set of parameters, but when I use those same parameters as inputs of a backtest in the strategy tester, a loss occurs.

Did this ever happen to anyone of you and if so, how did you fix it? Do you know what could cause such issues?

This is can be caused by coding bugs or issues in the EA, usually involving not properly setting initial values of global variables in the OnInit() event handler. It can also be caused by corrupted "cache" files.

However, in the case of MT5, it could also just be an "error" in your own vision, because you may be looking at the "Result" column (which is a combination of values), instead of looking at the "Profit" column, in the "Optimization Results" table.

TobiasBecker
78
TobiasBecker  
Fernando Carreiro:

This is can be caused by coding bugs or issues in the EA, usually involving not properly setting initial values of global variables in the OnInit() event handler. It can also be caused by corrupted "cache" files.

However, in the case of MT5, it could also just be an "error" in your own vision, because you may be looking at the "Result" column (which is a combination of values), instead of looking at the "Profit" column, in the "Optimization Results" table.


First of all, thank you for your answer.

I have used the optimizer with the same EA before and the results were consistent back then, so I believe there is no such bug inside of the EA.
It was indeed the "Profit" column I looked at, and those results listed there did not match the tester results.

Could you tell me how to fix the issue if it is caused by corrupted cache files, as you mentioned?

Thank you in advance,

Tobias

Fernando Carreiro
4457
Fernando Carreiro  
TobiasBecker: I have used the optimizer with the same EA before and the results were consistent back then, so I believe there is no such bug inside of the EA.

It was indeed the "Profit" column I looked at, and those results listed there did not match the tester results.

Could you tell me how to fix the issue if it is caused by corrupted cache files, as you mentioned?

The cache file problem occurs more often in MT4, so just to be clear, is this MT4 or MT5?

In both cases, if you use "File"->"Open Data Folder" and then navigate to the "tester" directory, and there you will find a sub-directory called "cache" (on MT5) or "caches" (on MT4). Just delete the contents of those directories.

However, don't be so quick to dismiss the "code bug" possibility. It can come up in the most unexpected ways, even if you never noticed it happen before. So, if you delete the cache files and the problem persists, then you can be almost sure that it is indeed a code problem.

Alain Verleyen
36160
Alain Verleyen  
TobiasBecker:

Hello,

I just optimized an EA of mine using the MQL Cloud Network. When I backtest the EA using those optimized parameters, the backtest results differ drastically from those reported by the optimizer.

Example:
In the optimization results, a big profit is reported for a given set of parameters, but when I use those same parameters as inputs of a backtest in the strategy tester, a loss occurs.

Did this ever happen to anyone of you and if so, how did you fix it? Do you know what could cause such issues?

Best regards,

Tobias

Which MT5 version are you using ?

Are you sure all initial values (input and trading environment are the same).

If all the inputs are the same, the output should be the same. If you are using a beta version it could be an MT5, otherwise it could be a typo or some input you didn't think about (conversion rate or stops level...). And finally it could be a bug as Fernando said.

TobiasBecker
78
TobiasBecker  

I am running on MT5 and just deleted the "cache" folder. Directly after that, there was an update available, which I installed. After restarting the terminal, I tried the old optimization results, which were inconsistent again.

However, after rerunning the optimizer the new optimization results are consistent, the problem seems to be solved. I have no Idea however, if the problem was solved by updating the terminal or if it was solved by deleting the cache files.

Marco vd Heijden
Moderator
8180
Marco vd Heijden  

On the first call the synchronization get's initialized so that it could be used on your second try after the update.

To add comments, please log in or register