Hi,
I get incorrect series array using (error 4054) in the sleep below, most of the time.
Am I doing the return handling correctly ? I have code like this:
MqlRates rates[];
int copied;
ArraySetAsSeries(rates, true);
for(int j=50; j>0; j--) {
ResetLastError();
copied = CopyRates(EURUSD, PERIOD_M15, 1, 20, rates);
int lastError = GetLastError();
if (lastError == ERR_NO_MQLERROR ||
lastError == ERR_NO_ERROR) {
break;
} else if (lastError == ERR_HISTORY_WILL_UPDATED ||
lastError == ERR_INCORRECT_SERIESARRAY_USING ) {
Print("Sleeping ", lastError, " ", j);
Sleep(250);
} else {
Alert("Fatal Error ", lastError, ":", ErrorDescription(lastError));
return 0;
}
}
Thanks.
Don't check for error when there is not. See CopyRates() documentation :
Return Value
Returns the number of copied elements or -1 in case of an error.
Thank you for your reply. I will try it out.
- 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,
I get incorrect series array using (error 4054) in the sleep below, most of the time.
Am I doing the return handling correctly ? I have code like this:
MqlRates rates[];
int copied;
ArraySetAsSeries(rates, true);
for(int j=50; j>0; j--) {
ResetLastError();
copied = CopyRates(EURUSD, PERIOD_M15, 1, 20, rates);
int lastError = GetLastError();
if (lastError == ERR_NO_MQLERROR ||
lastError == ERR_NO_ERROR) {
break;
} else if (lastError == ERR_HISTORY_WILL_UPDATED ||
lastError == ERR_INCORRECT_SERIESARRAY_USING ) {
Print("Sleeping ", lastError, " ", j);
Sleep(250);
} else {
Alert("Fatal Error ", lastError, ":", ErrorDescription(lastError));
return 0;
}
}
Thanks.