Historical chart data not downloading automatically in Metatrader 4 in some cases

 
I searched the forum and did not find a solution to my problem, so I'm opening a new thread. I do not rule out that the solution has been published somewhere, but I can not find it. If so, please, let me know and provide a link to the solution.

I created EA in MQL4 - a market scanner that works on many currency pairs and periods. The scanner uses several standard functions that require data from different pairs and periods: iMA, iVolume, iClose, etc. Scanned currency pairs are taken from the market watch panel. From what I understand, when a currency pair has no history downloaded from the broker to return the result of the function that references it, the request is sent to int the background to broker to get the missing data. And here the problem arises because for some combinations, the data is downloaded automatically, and for some it is not, I can not find the reason why. When I open the window of the graph for which the data was not collected, I only get a fragment of the chart from the moment the scanner was started up to the present. The only way to download the remaining data is to use the right mouse button and the function "Refresh" or start scrolling the chart back. This i how it looks like:

https://www.mql5.com/en/charts/9289085/usdcad-h1-admiral-markets

Calling iClose for such empty chart gets 0 as a result and the error returned is 4051 invalid function parameter value.

I can not find a solution to force the download of data from the broker server. Are there any security measures on the server side against too intensive parallel polling for data and too many polls causes the automatic data downloading mechanism to be turned off? Is there any way to program the forcing of such a refresh history at the start of the scanner?

Thank you in advance for your help.

Regards,

Marcin

Chart USDCAD, H1, 2018.10.26 14:58 UTC, Admiral Markets, MetaTrader 4, Real
Chart USDCAD, H1, 2018.10.26 14:58 UTC, Admiral Markets, MetaTrader 4, Real
  • www.mql5.com
Symbol: USDCAD. Periodicity: H1. Broker: Admiral Markets. Trading Platform: MetaTrader 4. Trading Mode: Real. Date: 2018.10.26 14:58 UTC.
 
Marcin Madrzak:

I can not find a solution to force the download of data from the broker server.

https://www.mql5.com/en/docs/series/timeseries_access
Look for the CheckLoadHistory() function.

https://www.mql5.com/en/articles/83
Look at init_tf(){} in the attached code.

 
Anthony Garot:

https://www.mql5.com/en/docs/series/timeseries_access
Look for the CheckLoadHistory() function.

https://www.mql5.com/en/articles/83
Look at init_tf(){} in the attached code.

 
Anthony Garot:

https://www.mql5.com/en/docs/series/timeseries_access
Look for the CheckLoadHistory() function.

https://www.mql5.com/en/articles/83
Look at init_tf(){} in the attached code.

Thank you for the tips. Running the following code gives the following results:

SeriesInfoInteger("AUDUSD",PERIOD_H1,SERIES_SERVER_FIRSTDATE) = D'2016.12.23 17:00
SeriesInfoInteger("AUDUSD",PERIOD_H1,SERIES_FIRSTDATE) = D'2018.10.26 16:00
SeriesInfoInteger("AUDUSD",PERIOD_H1,SERIES_BARS_COUNT) = 4

CopyClose("AUDUSD",PERIOD_H1,0,99,close_tmp_array)) = 4
GetLastError() = ERR_INVALID_FUNCTION_PARAMVALUE

CopyClose("AUDUSD",PERIOD_H1,5,99,close_tmp_array)) = -1
GetLastError() = ERR_NO_HISTORY_DATA

The problem is running CopyClose, CopyTime, iClose, iMA or whatever other function I'm trying does not force data download from the server and I'm stuck with 4 bars - in this example - until I manually Refresh the AUDUSD H1 chart. Still standing question is how to make MT4 download this data using code not mouse?

 
Anthony Garot:

https://www.mql5.com/en/docs/series/timeseries_access
Look for the CheckLoadHistory() function.

https://www.mql5.com/en/articles/83
Look at init_tf(){} in the attached code.

Is this topic about mql4 or mql5 ? as you reference are for mql5 only. They don't work the same in respect of collecting data, unless there was some change recently.
 
Alain Verleyen:
Is this topic about mql4 or mql5 ? as you reference are for mql5 only. They don't work the same in respect of collecting data, unless there was some change recently.

My question was about mql4 but since Anthony gave some references to mql5 and I was not able to find similar for mql4 I gave them a try but I was unsuccessful.

----

I updated the original post to make it clear it's about MT4 and mql4.

 
Alain Verleyen:
Is this topic about mql4 or mql5 ? as you reference are for mql5 only. They don't work the same in respect of collecting data

My mistake.

 
Maybe this could help you: https://www.mql5.com/en/forum/229215
Is there any way to load programmatically entire history (of a Symbol and a Period) from server?
Is there any way to load programmatically entire history (of a Symbol and a Period) from server?
  • 2018.03.01
  • www.mql5.com
I'm looking for programmatically solution of loading entire history for a symbol and a timeframe from server...
Reason: