I didn't get a response so I found a way to implement my own solution. Here is a class that will cut down your time to get the total bars in half. If you think about how many times you need this information in a test, this is huge. If you save the bars object for each symbol/tf then you can cut out the search time as well which might drop off another 1%.
Files:
BarsManager.mqh
4 kb
fxtrader1081:
I didn't get a response so I found a way to implement my own solution. Here is a class that will cut down your time to get the total bars in half. If you think about how many times you need this information in a test, this is huge. If you save the bars object for each symbol/tf then you can cut out the search time as well which might drop off another 1%.
Thanks for reporting back your results
I didn't get a response so I found a way to implement my own solution. Here is a class that will cut down your time to get the total bars in half. If you think about how many times you need this information in a test, this is huge. If you save the bars object for each symbol/tf then you can cut out the search time as well which might drop off another 1%.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am having a hard time with my ea being slow and after using the profiler, it seems the cause is the Bars function. Now, the bars function is being called in the Function I am using t ge the time of x bar. That is because as I understand it, I am using the CiTime class to get the time and as I understand it I must resize the buffer using the CiTime.BufferResize function unless am missing something. Here is the code.
CList timesLst;
datetime GetTime(string smbl, ENUM_TIMEFRAMES tf, int cndl)
{
int bars = Bars(smbl,tf);
int tot = timesLst.Total();
datetime toRet[];
for(int i=0;i<tot;i++)
{
CiTime *cit = timesLst.GetNodeAtIndex(i);
string smblHere = cit.Symbol();
ENUM_TIMEFRAMES tfHere = cit.Timeframe();
if(smblHere == smbl && tfHere == tf)
{
if(cit.BufferSize() != bars)cit.BufferResize(bars);
cit.GetData(cndl,1,toRet);
return toRet[0];
}
}
CiTime *cit = new CiTime();
cit.Create(smbl,tf);
cit.BufferResize(bars);
timesLst.Add(cit);
cit.GetData(cndl,1,toRet);
return toRet[0];
}