A question of using refreshrate() to refresh data on mutiple pairs

 

I am writing an EA to work with multiple pairs at same time. I attached the EA to EURUSD and the EA would do math on other 5 pairs as well.

The problem I found was that: the history data in the other 5 pairs did not refresh, except EURUSD, because the EA was ONLY attached to EURUSD. My solution was to add refreshrate() in the EA. But the problem remained.

My quesion is how to refresh data in other pairs that there is no EA attached to.

Thanks

 

I think as a minimum you will need the charts open (or in the Market Watch window), or no ticks will be received for the pairs in question.

It wouldn't matter what you did in your EA then, as no data would be received.

 
lostbridge:

I am writing an EA to work with multiple pairs at same time. I attached the EA to EURUSD and the EA would do math on other 5 pairs as well.

The problem I found was that: the history data in the other 5 pairs did not refresh, except EURUSD, because the EA was ONLY attached to EURUSD. My solution was to add refreshrate() in the EA. But the problem remained.

My question is how to refresh data in other pairs that there is no EA attached to.

Thanks

The RefreshRates function has a specific use

https://book.mql4.com/variables/predefined

Paul_B's suggestion is also what I do with 8 charts open in total. If that is not acceptable, for some good reason, then you can force a refresh on the other pairs even without their charts being open if you use a function call which requests more data such as ArrayCopyRates. This will get the data you require, but not immediately. I therefore prefer the open chart solution.

It looks like any of these functions will also force a refresh, but I haven't tried them for this purpose.

https://docs.mql4.com/series

 

I DID open the charts that I wanted, but sometimes the refreshrate did not work.

I tried something like this:

Print(iTime(pair,PERIOD_H1,0);

Sleep(5000);

Print(iTime(pair,PERIOD_H1,0);

What I found:

The 1st time that iTime run, the result was 0, which means that there was no data in history center. After sleep, it showed some data. My explanation was that the system downloaded from the server after it realized there was missing data.

dabbler: How do you feel about my explanation? Thanks

 
lostbridge:

dabbler: How do you feel about my explanation? Thanks

Yes, sounds good.

https://docs.mql4.com/series

You can check the GetLastError value as well. I find this happens mostly when you first open that profile or when you change accounts. All the charts will not be updated at the same time. In that case I sometimes wait for the rest of the charts to update then change the main chart timeframe in order to force a redraw.

Reason: