MQL4 Reference Timeseries and Indicators Access RefreshRates

RefreshRates

Refreshing of data in pre-defined variables and series arrays.

bool  RefreshRates();

Parameters

None.

Returned value

True if the data updated, otherwise false.

Note

This function is used when Expert Advisor has been calculating for a long time and needs data refreshing. Returns true if data are refreshed, otherwise returns false. The only reason for data cannot be refreshed is that they are the current data of the client terminal.

Expert Advisors and scripts operate with their own copy of history data. Data of the current symbol are copied at the first launch of the expert or script. At each subsequent launch of the expert (remember that script is executed only once and does not depend on incoming ticks), the initial copy will be updated. One or more new ticks can income while the Expert Advisor or script is operating, and data can become out of date.

Example:

   int ticket;
   while(true)
     {
      ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0,0,"expert comment",255,0,CLR_NONE);
      if(ticket<=0)
        {
         int error=GetLastError();
         //---- not enough money
         if(error==134) break;
         //---- 10 seconds wait
         Sleep(10000);
         //---- refresh price data
         RefreshRates();
         break;
        }
      else
        {
         OrderSelect(ticket,SELECT_BY_TICKET);
         OrderPrint();
         break;
        }
     }