![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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 try to dowload data 1 time by day at 00:01 and write this code and i want the data of previous day from 00:00 to 23:59
deb=TimeCurrent()-86460;
fin=TimeCurrent()-120;
for(int x=0;x<ArraySize(tab_pair);x++)
{
MqlRates rates[];
copied=CopyRates(tab_pair[x],1,deb,fin,rates);
if(copied>=0)
{
OpenFile= FileOpen(folder+"/"+StringSubstr(tab_pair[x],0,6)+".Bid.txt",FILE_CSV|FILE_READ|FILE_WRITE,";");
FileSeek(OpenFile, 0, SEEK_END);
for(int i=0;i<ArraySize(rates);i++)
{
if(rates[i].open<10) arondi=5; else arondi=3;
maDate=StringSubstr(TimeToString(rates[i].time),0,4)+StringSubstr(TimeToString(rates[i].time),5,2)+StringSubstr(TimeToString(rates[i].time),8,2);
FileWrite(OpenFile,maDate+" "+StringSubstr(TimeToString(rates[i].time),11,2)+StringSubstr(TimeToString(rates[i].time),14,2)+"00",
NormalizeDouble(rates[i].open,arondi),NormalizeDouble(rates[i].high,arondi),NormalizeDouble(rates[i].low,arondi),NormalizeDouble(rates[i].close,arondi)
,rates[i].real_volume);
}
FileClose(OpenFile);
}
}
Sometime it work, sometime it doesn't work. It staart everytime at the good hour (00:00) but it stop at a random hour, sometime at 19:40, sometime at 10:20???
Could you explain me my error please?
Thank's lot