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