I'm connected on a demo account during optimizing and backtesting.
I don't know how spread are managed. Being connected to the broker modify the spread ? I thought it was either within the history files or fixed.
I'm going to take some time to determine my spread, that's very important point. In addition, I will display the date actually taken during optimization to see if my problem depends on it.
I'm connected on a demo account during optimizing and backtesting.
I don't know how spread are managed. Being connected to the broker modify the spread ? I thought it was either within the history files or fixed.
I'm going to take some time to determine my spread, that's very important point. In addition, I will display the date actually taken during optimization to see if my problem depends on it.
If the number of trades taken is the same then it unlikely to be a difference in the date range used.
To check the Spread all you need to do is print it to the log from within deinit() then when the run is finished look at the journal and it will tell you the spread used for the whole run . . . unless you have been using variable spread from the Dukascopy data.
Thank you very much for your response.
I'have started optimizing with only 2 pass between 2010.06.01 and 2012.06.01 (sorry for French language) :
After restarting EA with both parameters settings separately (without optimizing) the results are:
- With first pass parameters:
![](https://c.mql5.com/mql4/forum/2012/08/20120817_1021_firstpassparameters_1.png)
- With second pass parameters:
![](https://c.mql5.com/mql4/forum/2012/08/20120817_1024_secondpassparameters_1.png)
The number of trades ("Total des Trades") are the same but the Profit of the second pass is slightly different. However, the beginning of log is very interesting:
- Log during optimizing (first pass) :
==> Log created ... ==> ET_CheckNewBars() : New bar detected at Tue Jun 01 00:15:00 2010
- Log during optimizing (second pass) :
==> Log created ... ==> ET_CheckNewBars() : New bar detected at Fri Mar 30 19:37:00 2007
In the second pass, mt4 sends 2007 whereas the start date is June 2010. Further, we see after few loops, that mt4 jumps from Mon Apr 02 08:01:00 2007 to Tue Jun 01 07:03:00 2010. That might explain why the profit is only slightly different. It doesn't take whole history, but just few bars at the beginning. I restarted this test several times with different dates and I had the same behavior.
For me, these tests confirm that my problem is linked with date and optimizing mode and you, what do you think ?
For me, these tests confirm that my problem is linked with date and optimizing mode and you, what do you think ?
The number of trades ("Total des Trades") are the same but the Profit of the second pass is slightly different.
![](https://c.mql5.com/mql4/forum/2012/08/20120817_1018_optimizing_1_2.png)
For me, these tests confirm that my problem is linked with date and optimizing mode and you, what do you think ?
I will admit my French is pretty much non-existent, but the total number of trades does not look the same to me.
From what I see from what you have posted I suspect you may be correct about the date.
I would compare each trade in each pass to see if the opening and closing are occuring at the same times (i.e. Trade1Pass1 = Trade1Pass2 ?)
RaptorUK has helped me several times with that reminder about the Print() I would liberally apply that throughout your code and see what comes back.
Oh and I found that if I add the "if(IsTesting())" or "if(IsOptimization())" before the Print() it saves having to go back and comment things out for live testing/trading.
Oh yes, between pass 1 and 2 there aren't the same number, I meant the number of trades between backtest and optimizing for pass 1 and pass 2 separately. We can see that the number of trades doesn't change for each pass but the profit of the pass 2 is different in optimization and backtesting.
I'm going to compare each trades.
Merci ! :)
Hi,
I've just compared my logs in optimization and backtesting and I confirm that my problem comes of the starting date. In optimization mode, after the first pass, mt4 executes several loops with a bad date (it takes the first dates of the historic). Therefore, the first position of the EA is shifted and the profit changes...
A log aggressive during the pass 2 in optimization :
==> Log opening successful ==> TimeCurrent : 2007.04.02 07:24 <--- Starts with the first date of the historic ==> TimeCurrent : 2007.04.02 07:24 ==> TimeCurrent : 2007.04.02 07:24 ==> TimeCurrent : 2007.04.02 07:24 ==> TimeCurrent : 2007.04.02 07:24 ==> TimeCurrent : 2007.04.02 07:24 ==> TimeCurrent : 2007.04.02 07:24 ==> TimeCurrent : 2007.04.02 07:24 (..) ==> TimeCurrent : 2007.04.02 08:06 ==> TimeCurrent : 2007.04.02 08:06 ==> TimeCurrent : 2007.04.02 08:06 ==> TimeCurrent : 2007.04.02 08:07 ==> TimeCurrent : 2007.04.02 08:07 ==> TimeCurrent : 2007.04.02 08:07 ==> TimeCurrent : 2010.07.01 00:57 <--- Jumps to starting date entered in mt4 only here ==> TimeCurrent : 2010.07.01 00:57 ==> TimeCurrent : 2010.07.01 00:57 ==> TimeCurrent : 2010.07.01 00:57 ==> TimeCurrent : 2010.07.01 00:57 ==> TimeCurrent : 2010.07.01 00:57 ==> TimeCurrent : 2010.07.01 00:57 ==> TimeCurrent : 2010.07.01 00:57 (..)
One possibility to overcome this bug is to delay the starting of the EA in order to begin after the bug. But, that assumes to know the starting date in the EA in adding one parameter which must be updated manually. That's boring and not compatible with no personal programs that launch automatically optimizing with command lines several times on different periods.
If someone has an idea to overcome it easily, I take :D
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone,
I'm new to mt4 and EA world and I have one question about optimization and dates settings.
I have been programming and backtesting an EA with Dukascopy's ticks data (I use Tick Data Suite). Once the EA optimized, I get the best parameters and I can set them directly by click right and select "Parameters". I launch a new simulation with these parameters (without optimization obviously) in order to see my beautiful positive curve. But I have remarked my profit is different that the previous optimization result whereas it uses the same EA's parameters.
After few researches in the mql4 forum and Tick Data Suite troubleshoot, It seems that mt4 has a problem with dates settings during optimization processing. If I understood well, the first pass uses the date entered correctly but the next passes use whole history data. In my case, the results of the first pass is effectively the same with optimization enable or not, but for the other passes, the results are different and I don't know what really dates are used.
Do you know this problem ? If it is that I think, Do you have any solutions to overcome it ?
Concretely, my aim is to optimize the EA on a given period time and test its robustness to another.
Thank you.