Optimizer not showing same results as back-test

 

Hello,

I have a problem whereby I am running the standard "MACD Sample" EA in the optimizer but getting different results than when I "Set input parameters" and do a back-test.  Here is some of the background:

 

1) Environment: MT4 Build 1010, Using MACD Sample EA, Windows 10 

2) Spread set to "20" (5 digit broker)

3) Optimization set to show all results (i.e. skip useless results is OFF)

4) Optimizing only 1 parameter - "trailing stop" - of the MACD Sample EA. 

5) Start the back-test in optimization mode.   There are 6 results with a small profit.

6) Right-click the first result and select "Set input parameters"

7) Back-test with these settings - the profit is slightly different!

 

This is a simple example, however there are circumstances where the results I have seen using other EAs where the optimizer and back-tester are significantly different (including # of trades, etc).

Does anyone know why this is happening?

Thanks in advance!

 
Most probably you have set the Spread in the tester to "Current" use a fix spread like 2 or 5
 
Please see points above - using a fixed spread of 20.
 
Have you tried manually introducing the input values?

In any case, you can try to modify the EA to make a log of the data around when orders are opened/closed, and check if you are getting exactly the same values. That might give you a hint of what is going on.
 
Guillermo:
Have you tried manually introducing the input values?

In any case, you can try to modify the EA to make a log of the data around when orders are opened/closed, and check if you are getting exactly the same values. That might give you a hint of what is going on.

Hi Guillermo,

Not sure what you mean by "manually" introducing the input values?  I am only optimizing a single parameter.

I can try logging things, but in the example I gave it was only the profit that changed.  This means I would need to calculate the profit to compare (and/or compare all the individual trades)?

Before I go to such lengths, I suppose I was hoping that someone may have come across this issue before and/or know why there may be a difference?

 

Thank you. 

 
Hi,

I mean simply introducing the values in the field manually instead of

6) Right-click the first result and select "Set input parameters"

You could try to simply add a Print() at the time of sending and closing orders, printing all the information about those orders (current price, stoploss/take profit values...). Then, compare the outputs and see where you start seeing differences.

Kind regards.

 
Guillermo:
Hi,

I mean simply introducing the values in the field manually instead of

6) Right-click the first result and select "Set input parameters"

You could try to simply add a Print() at the time of sending and closing orders, printing all the information about those orders (current price, stoploss/take profit values...). Then, compare the outputs and see where you start seeing differences.

Kind regards.

Thanks for the suggestion.  I have tried manually setting the parameter (I have also confirmed that "Set input parameters" sets the parameters correctly in the "Expert properties").

I will wait to see if anyone else has come across this before I attempt to do an in-depth analysis - not to mention I imagine it wont solve the problem unless there is something I'm doing wrong (if I am, I can't see what ;).  I figure someone else must have come across this before. 

 
You did not specify the tester settings - symbol, timeframe, testing mode, date ranges. This may be important.
 

Thanks for the response, Stanislav,

The settings are:  Timeframe: M5, Symbol EURUSD, IG Demo with Standard Broker data, Use date unchecked (presumably this means all data available), Non-visual mode, Spread 20, Genetic algorithm off. 

 
trader1232:

Thanks for the response, Stanislav,

The settings are:  Timeframe: M5, Symbol EURUSD, IG Demo with Standard Broker data, Use date unchecked (presumably this means all data available), Non-visual mode, Spread 20, Genetic algorithm off. 

If you are connected to your broker, you have a change in trading environment between the optimization pass and the backtest : either data, or swap, tickvalue...
 

Was that due to the "Delays" setting with "Random delay"?

I also found the discrepancy in repeated backtesting results !

Reason: