Good afternoon.
The situation is as follows: the strategy tester in optimization mode ran through 10 options for combinations of input parameters, and gave 10 results. When repeated runs over the same date range with the same set of parameters, the results are different, and repeated attempts also sometimes produce new results. By eye, 2-5 results are regularly repeated, the rest are most often new. If you do a run in the tester without optimization, the result is always the same. Moreover, optimization sometimes for this one set of parameters gives the same result as a single run. Question – why is this happening and how to solve it? All this for EURUSD for mid-2018. There was already a similar message for MQL4 but I have MQL5. There is a feeling that using the run OnTick() only on Open, High, Low, Close, and not every tick (one of the tester parameters)deviations more. History quality – 100%.
What I tried and did not help: disconnecting the terminal from the network, deleting and then automatically loading the history, starting the body in OnTick() only when a new bar appears
datetime LastCalculatedBarTime = 0;
In the above post for 2007, it is mentioned that the swap even on bars deleted in the past is taken by the current one, is this true now for MQL5? But at the same time, single runs in my case give the same result (maybe just a few times in a row lucky).
void OnTick()
{
MqlRates mrate[];
ArraySetAsSeries(mrate,true);
CopyRates(_Symbol,PERIOD_M2,0,5000,mrate);
if (LastCalculatedBarTime != mrate[1].time)
{
LastCalculatedBarTime = mrate[1].time;
*body*
}
}
Thank you already.
fxsaber
Any initialization is correct. The main thing is that it was.
arkfatalist
I’m confused, there are several thousand lines of code, and I don’t know where there may be problems.
Thank you for the link. Indeed, my expert Advisor repeatedly increases the number of elements (in the first dimension) of multidimensional arrays.
In General, I dug around with Your example, it is only clear that I do not have enough knowledge and skills to use function templates. And if you look from the other side? Let’s say my problem is caused by an erroneous initialization or an increase in the size of arrays. Suppose that a line is found where the initialization is incorrect, how do I make this initialization correct?
In the meantime, I will try to reduce the number of changes to the size of arrays and their initializations to one for each array.