Download MetaTrader 5
To add comments, please log in or register
Deposit to your account using bank cards via Gate2Shop
JefCrystal
88
JefCrystal 2014.04.05 16:06 

The Goal is to insure that the data is current and up 2 date before a Copy Rates. is Executed ....I been reviewing this article. https://www.mql5.com/en/docs/series/timeseries_access and would like 2 use some thing similar 2 CheckLoadHistory(InpLoadedSymbol,InpLoadedPeriod,InpStartDate); But I can not because SeriesInfoInteger is not implemented in 628

The Code I am using works but I have 2 change from using Time current 2 time a bars method. But this will not insure I am on the current bar . In the past I have reviewed and used The code posted from https://forum.mql4.com/53894 by WHRoeder and RaptorUK: My code is posted below theirs I know the error is most likely the if (!IsTesting()) dCurrentTime = TimeCurrent(); My concern is That when I get a failure. The Data may not be current using iMaximum_Records = CopyRates(EASymbol, EATimeFrame,0, 2048, Rates);

WHRoeder 2013.02.09 18:30 #
 

bool isHistoryLoading;
int init(){ isHistoryLoading = true; .. }
int start(){
   if (isHistoryLoading){
      dt=iTime(Symbol(),PERIOD_M1,0); if (dt == 0) return;
      // or if( !iBars(Symbol(), PERIOD_M1)) return;
      isHistoryLoading = false;
      int counted = 0;
   }
   else counted = IndicatorCounted();
   for(int iBar = Bars - 1 - counted; iBar >= 0; iBar--){ ...

Jeff Code

   while (bolNoHistory && iCounterNumber <= 5 && !IsStopped() && IsConnected())   
{
   //Keep trying to Copy Rates if Rates has not been retrieved from the server
   //while(iMaximum_Records == -1 && !IsStopped() && IsConnected() )

   if (!IsTesting()) dCurrentTime  = TimeCurrent();                     
   if (!IsTesting())    dt=iTime(Symbol(),PERIOD_M1,0);   
   //When back testing we need to use time of the bar
      if (IsTesting())  
   {
    if ( ArraySize(Time) > 0 )   dCurrentTime  = Time[0];                        
   
   }
   if (dt > 0)
  {    
   iMaximum_Records  =  CopyRates(EASymbol, EATimeFrame, dCurrentTime, paramNoOfRecords, Rates);                     
  } 
    
      if (iMaximum_Records < 0 || dt< = 0 ) 
   { 
      // --- moving 2 bar method over time . Other wise Copy Rates will fail
      iMaximum_Records = CopyRates(EASymbol, EATimeFrame,0, 2048, Rates); 
   }
   
   
   //If data has not been loaded, keep waiting 15 seconds each round
      if(iMaximum_Records == -1)
   { 
       // --- Turing on other error traps  once a failure happens 
      SetExternBool(EAName,EASymbol,EATypeOfTrade,EATimeFrame,Error63,1 );      
      SetExternBool(EAName,EASymbol,EATypeOfTrade,EATimeFrame,Error64,1 );
      Sleep(Sleep_Var);
   }
   
   //If not the most current, data is out of sync
   if (iMaximum_Records > 0                              &&
   iOpen (EASymbol, EATimeFrame,0) != Rates[0].open      && 
   iOpen (EASymbol, EATimeFrame,1) != Rates[1].open      &&
   iClose(EASymbol, EATimeFrame,1) != Rates[1].close     &&
   iLow  (EASymbol, EATimeFrame,1) != Rates[1].low       &&
   iHigh (EASymbol, EATimeFrame,1) != Rates[1].high      &&      
   iTime (EASymbol, EATimeFrame,1) != Rates[1].time      
   )
   {
     
    Print("iOpen: " + iOpen (EASymbol, EATimeFrame,0) + " != Rates[0].open: " + DoubleToStr(Rates[0].open) );
     break;
      
   }
 
   PrintFormat(EASymbol + " on " + EATimeFrame + ": No history downloaded on attempt # %i",intCount);
   intCount++;
   
   iCounterNumber++;

}   
/
To add comments, please log in or register