Calculate indicators across symbols get value wrong

 

My requirement is to calculate value across indicator of multiple symbols and get back result in whole, but looks like something got wrong that I can never guarentee all of the symbols outside of the current chart window is right.


Brief code is as follows:

void onStart()
{       
        int output = 0;
        RefreshRates();
        string symbols[20] = {"EURUSD","EURAUD","EURNZD",...};
        for (int i = 0; i <= 19; i++)
                output += calculateSymbol(symbols[i]);
        
}

int calculateSymbol(string symbol)
{
        return iRSI(symbol, <other_params>);
}

And execute on one chart, say, EURUSD.

I found the value done by EURUSD is always correct, but other values cannot be guarenteed - they change as per my behavior of executing the script by using Debug on MT4 Editor or Execute in trading platform. eg when using debug ,EURNZD might not correct, but using platform, EURNZD is right, GBPUSD & EURJPY is not.

Also the symptom varies across dates, like, I execute this on yesterday in Debug and found wrong in EURNZD, but execute on today in Debug, EURNZD is right, EURCAD not.


Update 1: My initial research found the reason might caused by some of the symbols were not correctly refreshed and the value was calculated by some timestamp in previous time. But I have refreshed the rate in script and All enlisted symbols are shown in market watch window.

Update 2: Looks like the trick is I didn't refresh the historical data for the symbols so that it goes wrong. But how to refresh the data if I want to make it automated (at least once every few hours) without opening the chart, eg, I want to execute script on EURUSD to refresh rate on EURCAD etc?

 
a4194304:

My requirement is to calculate value across indicator of multiple symbols and get back result in whole, but looks like something got wrong that I can never guarentee all of the symbols outside of the current chart window is right.


Brief code is as follows:

And execute on one chart, say, EURUSD.

I found the value done by EURUSD is always correct, but other values cannot be guarenteed - they change as per my behavior of executing the script by using Debug on MT4 Editor or Execute in trading platform. eg when using debug ,EURNZD might not correct, but using platform, EURNZD is right, GBPUSD & EURJPY is not.

Also the symptom varies across dates, like, I execute this on yesterday in Debug and found wrong in EURNZD, but execute on today in Debug, EURNZD is right, EURCAD not.


My initial research found the reason might caused by some of the symbols were not correctly refreshed and the value was calculated by some timestamp in previous time. But I have refreshed the rate in script and All enlisted symbols are shown in market watch window.

So what's wrong with my code and how to fix the problem?

Should iRSI be a double...?
 
andrew4789:
Should iRSI be a double...?
This is not what I'm concerning about,  it is just a rough example. The real phenomen is when I execute on EURUSD, I found EURCAD reports RSI 75, but acturlly now it is 71, and 75 was occurred some hours ago.
 
On MT4: Unless the current chart is that specific symbols/TFs referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
          Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4