I'm looking for programmatically solution of loading entire history for a symbol and a timeframe from server. I can do it manually by opening a chart with the required symbol and the required timeframe and then (unlock Scroll the chart button) by pressing Home and multiple pressing PgUp until I get to the oldest bar in the server history. But I need doing this by code (in the best way without opening the chart). Of course I can do it by programmatically opening the chart and simulating the keystrokes by API and then close the chart in the end. I was wondering if there is any easier solution? It may not be easier, but without opening and closing the chart and without API. Any Idea?
Programmaticly, you can get the last 2K bars.
The last 2K bars aren't my problem. I can get that very simple.
I need to get 32K (12K or 65K, entire broker's server history ) bars of history per timeframe. I can get that manually (or programmatically by simulating keystrokes) but I'm looking for another programmatically solution.
Tickstory from www.tickstory.com already does that
You need to open the chart in all cases. If by API you mean WinAPI you don't need that, it can be done without it, using ChartNavigate().
Thank you Alain,
as usual, is your contribution to the matter. I'll try that and write the result here.
void updatehist(string sym, ENUM_TIMEFRAMES tf)
long id = ChartOpen(sym, tf);
ChartSetInteger(id, CHART_AUTOSCROLL, false);
datetime oldest_serv = (datetime)SeriesInfoInteger(sym, tf, SERIES_SERVER_FIRSTDATE);
while(ChartGetInteger(id, CHART_AUTOSCROLL) == true)
datetime current = iTime(sym, tf, iBars(sym, tf) - 1);
LabelCreate(id, "txt1", 0, 10, 40, CORNER_LEFT_UPPER, "Loading history.. Please wait..", "Consolas", 28, clrTurquoise);
LabelCreate(id, "txt2", 0, 10, 80, CORNER_LEFT_UPPER, "Current " + (string) current + " of " + (string)oldest_serv, "Consolas", 28, clrTurquoise);
while((int)oldest_serv < (int)current && !IsStopped())
ObjectSetString(id, "txt2", OBJPROP_TEXT, "Current " + (string) current + " of " + (string)oldest_serv);
ChartNavigate(id, CHART_CURRENT_POS, -1000);
current = iTime(sym, tf, iBars(sym, tf) - 1);
This should work well.. LabelCreate() functions from MQL4 help
Please enable the necessary setting in your browser, otherwise you will not be able to log in.