Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello,
I have this code that works fine if called from the same script.
But if it is stored in a mq4 library ( mqr file library and a header). It does not copy the rates.
How should I use or modified this function or declare the array in the calling script in order to
get copied rates correctly. Thanks in advance.
bool copy(string symbol, int timeframe, double &array1[][6]){
int error=0;
int numberOfCopiedCandles=0;
int sleepTime=500;
numberOfCopiedCandles=ArrayCopyRates(array1,symbol, timeframe);
error=GetLastError();
if(error==4066)
{
numberOfCopiedCandles=0;
for(int i=0;i<3; i++)
{
Sleep(sleepTime);
numberOfCopiedCandles=ArrayCopyRates(array1,symbol, timeframe);
error=GetLastError();
if(error==4066)
{
numberOfCopiedCandles=0;
Sleep(sleepTime);
numberOfCopiedCandles=ArrayCopyRates(array1,symbol, timeframe);
}
}
if(i>=3 && error==4066){
return(false);
}
}
return (true);
}