Any candle related function does that. The test is for the error and not to continue until download completes.
I came across this thread when I was trying to load TF data for a chart running an EA, so I could get iATR(100) on various TFs even if there was no data loaded.
bool DownloadHistory(int period=0, string symbol="")
string fn = __FUNCTION__ + "()";
if (symbol == "") symbol = Symbol();
if (period == 0) period = Period();
for (int i=0; i < 5; i++)
datetime other = iTime(symbol, period, 0);
if (_LastError == 0 && other != 0)
if (_LastError != ERR_HISTORY_WILL_UPDATED && _LastError != ERR_NO_HISTORY_DATA)
Debug(1, fn, "iTime(" + symbol + ", " + period + ", 0) Failed. Error = " + _LastError);
else // we need to wait for it to load
It seemed to work pretty well, running it on 28 charts, except I kept getting an error on AUDNZD only when it tried to load H4 data, which was odd because the chart was on H4. Eventually I just used the home key to load more and it went away.
But using the iTime() function only loads the minimal which appears to be 120.1 KB. I wondered if anyone had a method for MT4 to make it load all data (like holding the 'Home' key) or a certain amount of data.
Substituting a variuable 'bar' for zero, I tried this:
int bar = iBars(NULL, 30);
bar = bar + iBars(NULL, PERIOD_M30);
DownloadHistory(PERIOD_M30 , Symbol(), bar);
But it only resulted in a error 4051. Anyone ever figure a way to load 'X' bars of data, or to load all?
Don't answer all-at-once. I'm very patient.
Thank you for the response. The link you sent seems to be a manual method. I was attempting to find a way to do it programmatically.
But that's still a pretty good trick for manually getting it :-)
Please enable the necessary setting in your browser, otherwise you will not be able to log in.