Download MetaTrader 5
To add comments, please log in or register
Having difficulties in understanding the Trading Signals service? Read the article!
neo-13
87
neo-13 2014.12.05 14:51 

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

/
To add comments, please log in or register