How to force loading of history?

 
I wish to download history from my broker. This is so I have history for backtesting. I have previously done this by opening each chart and clicking on each timeframe until all the history is filled. This takes from 30 min to one hour depending on the time of day and the number of pairs to download.
I would like to automate this so I don't have to sit in front of my terminal clicking and clicking. I have tried accessing iTime, iHigh and similar functions in a script.
I start at shift 0 and work my way back until it returns 0 then wait a while and access again. A while varies from 100 to 5000 ms. using sleep function.
Invariably I run into a wall on 1 minute data of from 2000 to 4000 bars. Yet, if I click on the chart, I can get at least 100000 bars ( a little over 1 week).
Any ideas how to force a download of history? my broker is InterbankFX.
Thanks in advance for your help.
 
"Yet, if I click on the chart, I can get at least 100000 bars ( a little over 1 week)."

A week of 1m = 1440 x 5 = 7200 bars
--------------------------

What setting do you have in Tools -- Options -- Charts ?

I opened a "new" 1m chart, one I never use, and got 59,221 bars immediately, using Velocity4x server
 
i just cleared the history for eur/usd and ran my script which attempts to backup on ihigh. It got to 2048 bars (10.30.2007 15.33) and hung. I reloaded and started again and it got to the same point.
My chart settings are the default - the chart is on 5 minutes and i am requesting 1 min. data.
The chart check boxes checked are:
Chart on foreground
Chart shift
Chart autoscroll
candlesticks
show ohlc
show period separators
show grid
Sorry about the arithmetic, i guess 100000 is somewhat more than a week. (quite a bit) LOL
here is my code based on a standard script supplied with the platform
//+------------------------------------------------------------------+
//|                                                        trade.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#include <stdlib.mqh>
#include <WinUser32.mqh>

int FriClose=20;
int SunOpen=20;
//+------------------------------------------------------------------+
//| script "trading for all money"                                   |
//+------------------------------------------------------------------+
int start()
  {
//----
 //----
   int iShift;
   int iStart; //Starting shift for getting data
   int iMaxPeriod = 60*60*24*14; // two weeks of datetime
   int iPeriod = PERIOD_M1;
   int iLimit; //max no. of bars retrieved
   int incr;
   int iLast;
   int iter,iterlim;
   datetime dShift,dStart;
   datetime dNow;
   datetime dLimit;
   //dNow = StrToTime("2007.10.14 21:43");
   //Print (TimeToStr(dNow)," ",TimeToStr(Prev(dNow))," ",TimeToStr(Next(dNow)));
   //dNow = StrToTime("2007.10.14 20:43");
   //Print (TimeToStr(dNow)," ",TimeToStr(Prev(dNow))," ",TimeToStr(Next(dNow)));
   //dNow = StrToTime("2007.10.14 19:43");
   //Print (TimeToStr(dNow)," ",TimeToStr(Prev(dNow))," ",TimeToStr(Next(dNow)));
   //dNow = StrToTime("2007.10.13 21:43");
   //Print (TimeToStr(dNow)," ",TimeToStr(Prev(dNow))," ",TimeToStr(Next(dNow)));
   //dNow = StrToTime("2007.10.12 21:43");
   //Print (TimeToStr(dNow)," ",TimeToStr(Prev(dNow))," ",TimeToStr(Next(dNow)));
   //dNow = StrToTime("2007.10.12 20:43");
   //Print (TimeToStr(dNow)," ",TimeToStr(Prev(dNow))," ",TimeToStr(Next(dNow)));
   //dNow = StrToTime("2007.10.12 19:43");
   //Print (TimeToStr(dNow)," ",TimeToStr(Prev(dNow))," ",TimeToStr(Next(dNow)));
   bool bFound;
   string sSym = "EURUSDm";
   iStart=GetData(sSym,1);
   iLimit = 60*60*24*10; // two weeks of minute bars
   incr=128; // one hour of minute bars
   iStart=0;
   iLast=0;
   dStart=dNow;
   dNow = TimeCurrent();
   iPeriod = PERIOD_M1;
   iter=0;
   iterlim=10;
   bFound=false;
   while ((iStart<iLimit) && (iter<iterlim))
     {
 
      if (iHigh(NULL,iPeriod,iStart)>0)
         {
          iLast=iStart;
          iter=0;
          Print ("1 error,iter, incr, iStart,iTime=",GetLastError()," ",iter," ",incr," ",iStart," ",TimeToStr(iTime(NULL,iPeriod,iStart)));
          iStart=iStart+incr;
         }
       else
         {
          if (incr>1)
            {
             Print ("2 error,iter, incr, iStart,iTime=",GetLastError()," ",iter," ",incr," ",iStart," ",TimeToStr(iTime(NULL,iPeriod,iStart)));
             incr=MathRound(incr/2);
             iStart=iLast+incr;
            }
          else
            {
             Sleep(5000);
             Print ("3 Just Slept error,iter, incr, iStart,iTime=",GetLastError()," ",iter," ",incr," ",iStart," ",TimeToStr(iTime(NULL,iPeriod,iStart)));
             incr=1;
             iter++;
            }
         }
 //        Print ("Just Slept iter, iStart,iTime=",iter," ",iStart," ",TimeToStr(iTime(sSym,iPeriod,iStart)));
     }
   
   
   
   
   int nEUR=iBars(sSym,iPeriod);
   Print ("No of bars of ",sSym," in period M1 is ",nEUR);
   Print("Time of bar ",nEUR," is ",TimeToStr(iTime(sSym,iPeriod,nEUR)));
   return(0);
  }
 int GetData(string sSym,int iPeriod)
   {
    datetime x = Next(0 );
    return(Prev(0));
   }
// Prev gives previous week if input is in weekend
// Should be corrected for DST

datetime Prev(datetime dTime)
   {
    int dRTime=0;
    int dHour=0;
    int dMinute=0;
    if ((TimeDayOfWeek(dTime)==5) && (TimeHour(dTime)>=FriClose))
      {
       dHour = TimeHour(dTime)-FriClose;
       dMinute = 1 + TimeMinute(dTime);
      }
    if (TimeDayOfWeek(dTime)==6)
      {
       dHour = TimeHour(dTime) + 24 - FriClose;
       dMinute = 1 + TimeMinute(dTime);
      }
    if ((TimeDayOfWeek(dTime)==0) && (TimeHour(dTime)<SunOpen))
      {
       dHour = TimeHour(dTime)+48 -FriClose;
       dMinute = 1 + TimeMinute(dTime);
      }
    dRTime = (dHour*60 + dMinute)*60;
    return(dTime-dRTime);
   }
// Next gives next week if input is in weekend
// Should be corrected for DST
datetime Next(datetime dTime)
   {
    int dRTime=0;
    int dHour=0;
    int dMinute=0;
    if ((TimeDayOfWeek(dTime)==5) && (TimeHour(dTime)>=FriClose))
      {
       dHour = 48 - TimeHour(dTime) + SunOpen;
       dMinute =  0-TimeMinute(dTime);
      }
    if (TimeDayOfWeek(dTime)==6)
      {
       dHour = 24 - TimeHour(dTime) + SunOpen;
       dMinute = 0-TimeMinute(dTime);
      }
    if ((TimeDayOfWeek(dTime)==0) && (TimeHour(dTime)<SunOpen))
      {
       dHour = 0 - TimeHour(dTime) + SunOpen;
       dMinute = 0 - TimeMinute(dTime);
      }
    dRTime = (dHour*60 + dMinute)*60;
    return(dTime+dRTime);
   }
   
//+------------------------------------------------------------------+
 
You listed "Chart Properties"...

There is a setting under the menu item Tools -- Options --- Chart Tab

where you set the number of bars in history, and on charts. I do not know what
the default is. Make it big.

Also, Menu -- Tools -- history Center
Click on any grayed out icons to collect bars from the server. When green, I think they continue to collect.

Beyond that, no idea.

I didn't look at your code.

Good luck.
 
the number of bars in both history and charts is 99999999.
The history center icon was green for the 1 min data.
I don't wish to use the history center to retrieve the data as it gets data from the MetaQuotes Software server,
not the InterbankFx server. I have loaded data from both servers and compared them and they are slightly different.
Is there any way to programatically manipulate the chart - load it, change what is being viewed? The only thing I see in the MQL4 dictionary are the window functions which appear to tell you what is being displayed but don't let you change it. The object functions appear to let you put graphics on the chart but if you place a graphic on an undisplayed portion of the chart, it doesn't force a display. correct?
My theory is if i can simulate what i do when clicking on the chart, perhaps that will force an update. - in other words, attempt to move the displayed chart to a portion which has no history to force the system to load history.
Here is a simplified version of the code which I have been using.
//+------------------------------------------------------------------+
//|                                                        trade.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#include <stdlib.mqh>
#include <WinUser32.mqh>
//+------------------------------------------------------------------+
//| script "get history"                                   |
//+------------------------------------------------------------------+
int start()
  {
//----
 //----
   int iShift;
   int iStart; //Starting shift for getting data
   int iMaxPeriod = 60*60*24*14; // two weeks of datetime
   int iPeriod = PERIOD_M1;
   int iLimit; //max no. of bars retrieved
   int incr;
   int iLast;
   int iter,iterlim;
   datetime dShift,dStart;
   datetime dNow;
   datetime dLimit;
   bool bFound;
   string sSym = "EURUSDm";
   iLimit = 60*24*10; // two weeks of minute bars
   incr=128; // one hour of minute bars
   iStart=0;
   iLast=0;
   dStart=dNow;
   dNow = TimeCurrent();
   iPeriod = PERIOD_M1;
   iter=0;
   iterlim=10;
   bFound=false;
   while ((iStart<iLimit) && (iter<iterlim))
     {
 
      if (iHigh(NULL,iPeriod,iStart)>0)
         {
          iLast=iStart;
          iter=0;
          Print ("1 error,iter, incr, iStart,iTime=",GetLastError()," ",iter," ",incr," ",iStart," ",TimeToStr(iTime(NULL,iPeriod,iStart)));
          iStart=iStart+incr;
         }
       else
         {
          if (incr>1)
            {
             Print ("2 error,iter, incr, iStart,iTime=",GetLastError()," ",iter," ",incr," ",iStart," ",TimeToStr(iTime(NULL,iPeriod,iStart)));
             incr=MathRound(incr/2);
             iStart=iLast+incr;
            }
          else
            {
             Sleep(5000);
             Print ("3 Just Slept error,iter, incr, iStart,iTime=",GetLastError()," ",iter," ",incr," ",iStart," ",TimeToStr(iTime(NULL,iPeriod,iStart)));
             incr=1;
             iter++;
            }
         }
 //        Print ("Just Slept iter, iStart,iTime=",iter," ",iStart," ",TimeToStr(iTime(sSym,iPeriod,iStart)));
     }
   
   
   
   
   int nEUR=iBars(sSym,iPeriod);
   Print ("No of bars of ",sSym," in period M1 is ",nEUR);
   Print("Time of bar ",nEUR," is ",TimeToStr(iTime(sSym,iPeriod,nEUR)));
   return(0);
  }


It first takes giant steps backward until it goes past the wall then cuts the steps in half until it finds the wall and then keeps trying to break through, waiting a little between each attempt.
I am posting this here in the hopes that someone from metaquotes can tell me how to do this, or what I am doing wrong.

 
I think we still don't have solution to force data from broker's server. My broker (Sky East) couldn't answer my question about this. So, the best way to get them is exchanging data between us.
It's clear that the history data between Meta4 and broker's are different. The result of EA will definetly be different.
Reason: