RefreshRates() - page 2

 
RaptorUK:

Can you make this addition and re-run it please.


20:20:27 test #FDXU2,Daily: iHigh(Symbol(), PERIOD_M1, 1): 6767
20:20:27 test #FDXU2,Daily: iLow(Symbol(), PERIOD_M1, 1): 6766.5

20:20:27 test #FDXU2,Daily: iTime(Symbol(), PERIOD_M1, 1): 2012.07.31 20:19:00

This time the returned data matches the data I see in history center! I don't understand this.

 
TradeIT:

This time the returned data matches the data I see in history center! I don't understand this.


I must admit, neither do I . . .

What Operating System are you running ? and is your MT4 installed in Program Files ?

 
RaptorUK:


I must admit, neither do I . . .

What Operating System are you running ? and is your MT4 installed in Program Files ?

WinXP SP3

It is MetaTrader 4.

I've installed multiple instances of MT4

C:\Programme\MetaTrader\MetaTrader18

 
TradeIT:

WinXP SP3


OK, I'm out of ideas . . . if I think of anything I'll post again.
 
RaptorUK:

OK, I'm out of ideas . . . if I think of anything I'll post again.

OK. Thanks for your help!

I watch this behaviour over the next days to see whether this happens again.

Bid and Ask never had any problems though. Just iHigh() and iLow() had this issue. Maybe it is some sort of a caching thing? Is there some cache to clean?

 

Hi,

Try this ?!?

Refresh the chart:

#include <WinUser32.mqh>

PostMessageA(WindowHandle(Symbol (), Period ()), WM_COMMAND, 33324, 0);

Read the article https://www.mql5.com/en/articles/1407

:D

 
RaptorUK:

OK, I'm out of ideas . . . if I think of anything I'll post again.


I have been thinking and experimenting a little today :-)

I think the "issue" we are seeing is due to the fact that we are using a script. I'm guessing that once the history tries to update the updated history is not available until the next tick, and a script won't "see" the next tick . . . but an EA will . . .

Try the attached EA, what you should see is that for the first tick it runs you will get an error 4066 and for subsequent ticks the error will go away and the data will be correct. All the info is reported and updated to the screen top left. It only updates every 5 seconds, so you have a chance to see what is being put on screen.

Files:
 
RaptorUK:


I have been thinking and experimenting a little today :-)

I think the "issue" we are seeing is due to the fact that we are using a script. I'm guessing that once the history tries to update the updated history is not available until the next tick, and a script won't "see" the next tick . . . but an EA will . . .

Try the attached EA, what you should see is that for the first tick it runs you will get an error 4066 and for subsequent ticks the error will go away and the data will be correct. All the info is reported and updated to the screen top left. It only updates every 5 seconds, so you have a chance to see what is being put on screen.


Great! That's working today. But I'll keep checking over the next days ;)

So it is: RefreshRates() -> wait until 4066 is gone -> wait for next tick -> RefreshRates()

This "wait for next tick" step: I currently do a Sleep(5000). Could you think of any way to replace this Sleep(5000) with something dynamic?

Something that tells the function when the next tick has come in?

 
TradeIT:

Great! That's working today. But I'll keep checking over the next days ;)

So it is: RefreshRates() -> catch 4066 -> wait for next tick -> RefreshRates()

This "wait for next tick" thing: I currently do a Sleep(5000). Could you think of any way to replace this Sleep(5000) with something dynamic?

Something that tells the function when the next tick has come in?


In an EA you don't need to worry about that, start() is run on each tick . . . assuming it completes in time for the next tick.
 
If your just using an EA then have your code in the start(), it gets called everytime a new tick arrives. Also RefreshRates() doesn't refresh the history only pre-defined variables as Raptor said earlier. If you wanted to make sure that your history is up to date then run a iHigh on all the time frames which your using during the init() (or the very start of your script) then wait for the 4066's to finish. The data should be downloaded and you shouldn't have a 4066 problem later on.
Reason: