My EA seems to be in a loop! Help please! - page 3

 
szgy74:

Can you please show me a working example of 4066 checking?

I have several problems with the update of missing history data but NEVER got the 4066 (with GetLastError), I tried many places (in the code).


Read here: https://www.mql5.com/en/forum/143422 and here https://www.mql5.com/en/forum/145905 . . .

And from here: http://www.forexfactory.com/showthread.php?t=438824

  int GLError = 0;



      GLError = 4066;
      while(GLError == 4066)
         {
         iOpen("AUDCAD",15,0);
         iHigh("AUDCAD",15,0);
         iLow("AUDCAD",15,0);
         iClose("AUDCAD",15,0);
         GLError = GetLastError();
         if(GLError == 4066) Sleep(15000);
         }
 

Thank you, I will read and try these.
 
szgy74:

Can you please show me a working example of 4066 checking?

I have several problems with the update of missing history data but NEVER got the 4066 (with GetLastError), I tried many places (in the code).

  1. You won't get 4066 unless you shut down the terminal and delete the history files.
  2. Instead of using ACR you can use iTime() same result
       ArrayCopyRates(m1.acr, market.pair, PERIOD_M1);          // I'm in an OnInit.
       //}
    }  // OnInitAnalyze
    :
       if(m1.acr[0][ACR_TIME] == 0.){                         // Verify M1 data.
          int      gle   = GetLastError();
          if (gle != ERR_HISTORY_WILL_UPDATED){  DisableTrading("No M1 history: "
                                                    + GetLastError());   return;  }
          Print("Updating history for M1 chart");
          Sleep(15000);  RefreshRates();
          if(m1.acr[iCB][ACR_TIME] == 0.){
             DisableTrading("Updating history for Minute chart failed: "
                                                    + GetLastError());   return;  }
          Print("Updating history for Minute chart Succeeded");
       }  // M1 data
    

 
WHRoeder:
  1. You won't get 4066 unless you shut down the terminal and delete the history files.
  2. Instead of using ACR you can use iTime() same result

Thank you, I will try this too.