Variables and libraries

 

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);

}