Offline chart won't update unless open

Back to topics list To post a new topic, please log in or register
Hoodlum 2015.08.06 23:54

I'm using some code in an indicator to generate synthetic instruments for currency indexes, and storing the results in an offline chart. Once per minute, the code syncs data and writes new bars to the offline charts. The indicator then references the generated bars from the offline charts using iBars/iTime/iBarShift etc to generate a dashboard of summary information.

When I go to "Open Offline" and browse to one the offline charts that has been generated, the date in the "To" column is correctly identified as the time of the most recent bar as it should be. However, iBars/iTime/iBarshift - basically anything that allows you to reference data from another chart - only recognises bars up until the last time I actually had the offline chart in question physically open in MT4, and either hit "Refresh" manually, or forced an update.

For example, I shut down my MT4 instance 2 hours ago, and re-opened just now. The indicator did its work, and generated 2 hours of missing bars, which was verified by looking at the "To" column under the "Open Offline" menu. However, iBars/iTime etc were insistent that the last bar in the chart was still back from 2 hours ago. When I actually opened the offline chart, the new bars would not appear until a "Refresh" command was run, or the chart was forced to update via code using PostMessageA. After doing this, iBars/iTime etc started working as expected.

If I have all of the offline charts that are generated actually open in MT4 at once in addition to the indicator that generates them on a different chart, within code I can find the window handle for them, and force an update. However, this is far from ideal - I don't want to have a bunch of charts open on the screen I don't need, simply to get MT4 to recognise that the data in them has been refreshed.

Another possible workaround is to write a function to load the rates manually from the offline charts into a MqlRates array - but I'd rather not do this since I'd then have to write my own versions of iTime/iBarshift etc to find and reference specific bars within the rates array.

Is there some way to force an offline chart to "recognise" that new data has been appended such that iTime/iBarshft etc are aware of the new data, without physically having the offline chart open in MT4 and using the PostMessageA method to force them to update?

Hope this makes some sense. I've not posted any code since I'm discussing concepts, rather than having any problems with specific lines of code.

Thanks in advance for any input.


Edit: in fairness, if I went down the route of manually loading a MqlRates array from an offline file, I would only need to implement iBarShift using a binary search, since then open/high/low/close/volume are then accessible as properties on the rate struct. From what I've read on other forum posts, I suspect this may be the only way to get "up to date" data returned from an offline chart that isn't currently open within MT4.

It's still a little frustrating though that is a limitation that only seems to apply to offline charts - there is no problem reading the latest rates from "normal" charts even if they aren't actually currently open.

Ovo 2015.08.07 09:17 #

Yes, despite they announced implementation of access to the closed offline charts, quite time ago, it never worked.

I wonder if you still continue in re-implementation of functions for accessing the chart file. I think the problem is not the iTimeShift, the problem is that this solution is not universal.

Back to topics list  

To add comments, please log in or register