Download MetaTrader 5

How can I know local history is updated?

To add comments, please log in or register
All articles are available from MetaTrader 5. Contribute your own one!
1313
32
1313 2014.07.03 18:10 

Hi

Say like I want to get yesterday's close price of GPBUSD daily bar, while I'm in EURUSD 1H chart window.  The function iClose("GBPUSD",1440,1) will return 0 if local history is empty; but how can I know the returned price is actually for yesterday? If local history is not updated does it return incorrect price?

honest_knave
Moderator
2241
honest_knave 2014.07.03 18:25  

 iClose

 

Returned value
Close price value for the bar of specified symbol with timeframe and shift. If local history is empty (not loaded), function returns 0. To check errors, one has to call the GetLastError() function.

 

It should be the correct price, or 0.

1313
32
1313 2014.07.03 21:20  

I waited to the end of the day and I checked it myself. Unfortunately it returns incorrect prices.

For example the last time daily chart for AUDCAD was opened was at July 3rd. And when I ran the script on July 4th, the function iClose("AUDCAD", 1440,1) returned the close price of July 2nd (bar shift=1 relative to last bar known in history: july 3rd). The history is practically "not empty", but it's not updated. 

Is there anyway to force history data to be updated before returning results? Or I have to manually open up each chart to get it updated in history? 

qjol
3243
qjol 2014.07.03 23:44  
maybe july 4's bar doesn't exist (USA independence day)
whroeder1
14543
whroeder1 2014.07.04 01:51  
1313: July 4th, the function iClose("AUDCAD", 1440,1) returned the close price of July 2nd
How can you expect to get July 4th bar when your post was 2014.07.03 23:20 (one bar back IS JULY 2nd)
qjol
3243
qjol 2014.07.04 02:47  
WHRoeder:
1313: July 4th, the function iClose("AUDCAD", 1440,1) returned the close price of July 2nd
How can you expect to get July 4th bar when your post was 2014.07.03 23:20 (one bar back IS JULY 2nd)

maybe he lives in asia (australia japan... or even russia) and uses a broker who's using local time (australia...) the systems clock (here) is europa time
whroeder1
14543
whroeder1 2014.07.04 15:01  
qjol: maybe he lives in asia (australia japan... or even russia) and uses a broker who's using local time (australia...) the systems clock (here) is europa time
If that is the case, it puts his chart one day ahead of 2014.07.03 23:20 and a shift of one means the close would be 07.03. Still can't get July 4th.
1313
32
1313 2014.07.04 22:05  

İ tested the function in first minutes of July 4th on my mt4 server time! 

I've come to conclusion that history is not updated if the chart is not opened manually :| So, is there any way to do this without opening charts?

My main idea is to run a script to get prices of previous day on all symbols. But it seems I have no way to do this unless I open all charts to get them updated and then run the script... That's a pain..

Ian Venner
2584
Ian Venner 2014.07.04 23:11  
It is supposed to be updated if the pair is selected in the Market Watch window.
whroeder1
14543
whroeder1 2014.07.05 02:05  
1313: I've come to conclusion that history is not updated if the chart is not opened manually :
How do you come to that conclusion? There are no mindreaders here.
Halley
198
Halley 2014.07.05 05:55  
WHRoeder:
1313: I've come to conclusion that history is not updated if the chart is not opened manually :
How do you come to that conclusion? There are no mindreaders here.


Actually I know what he means. I had been waiting for some authorized answer, but nothing comes. The timeframes that do not appear on some chart do not get updated until an MQL read request is made, like iBars. In that case the last 2048 bars are updated. But there is no method I would know about to learn the data is already up-to-date.

123
To add comments, please log in or register