Different currency pair data for same chart (gives 0)

 

I am struggeling with this on the 5 min chart for GBPJPY. First "movAverA" gives correct value (ex. 141.5), but second "movAverB" always gives 0. What do I have to do different?
barIndex is the index for each bar (looped).

double movAverA = iMA("GBPJPY", 5, 12, 0, MODE_EMA, PRICE_CLOSE, barIndex); 

double movAverB = iMA("USDJPY", 5, 12, 0, MODE_EMA, PRICE_CLOSE, barIndex); 

 
ActiveTraderNor:

I am struggeling with this on the 5 min chart for GBPJPY. First "movAverA" gives correct value (ex. 141.5), but second "movAverB" always gives 0. What do I have to do different?
barIndex is the index for each bar (looped).

double movAverA = iMA("GBPJPY", 5, 12, 0, MODE_EMA, PRICE_CLOSE, barIndex); 

double movAverB = iMA("USDJPY", 5, 12, 0, MODE_EMA, PRICE_CLOSE, barIndex); 

When using Multi-symbol or Multi-timeframe in Indicators or EA's, you have to properly detect and react to 4066/4073 errors.

Have a look at the following thread for some details: https://www.mql5.com/en/forum/158938

Anyone know how to develop a multicurrency indicator ?
Anyone know how to develop a multicurrency indicator ?
  • 2016.04.21
  • www.mql5.com
Anyone know how to develop a multicurrency indicator ? I want to choose BETWEEN 1 to 10 different currencies and 5 bars for each currency...
 
Fernando Carreiro:

When using Multi-symbol or Multi-timeframe in Indicators or EA's, you have to properly detect and react to 4066/4073 errors.

Have a look at the following thread for some details: https://www.mql5.com/en/forum/158938


Thank you very much. This did solve my problem :-)
MqlRates mqlRatesForPair[];
int numberOfBarsCopiedToArray = ArrayCopyRates(mqlRatesForPair, symbolForPair, timeFrameForPair);
(added this in a function in an includefile + some code for error handling etc).

 
ActiveTraderNor:

Thank you very much. This did solve my problem :-)
MqlRates mqlRatesForPair[];
int numberOfBarsCopiedToArray = ArrayCopyRates(mqlRatesForPair, symbolForPair, timeFrameForPair);
(added this in a function in a includefile + some code for error handling etc).

You don't have to use the ArrayCopyRates to solve your problem if you don't need access to that information.

You only need to do properly handling of the 4066 and 4073 errors in all functions that require access to the other Symbols or Time-frames.

 
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. On MT4: Unless the current chart is the specific pair/TF referenced, you must handle 4066/4073 errors.
              Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

  3. Don't assume that index for the current chart is the same on other charts; use iBarShift.
 
whroeder1: Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
Just a note! I have not seen the moderators move threads in to (or out of) the MT4/MQL4 section lately, so I am assuming they are no longer worried about that issue and allowing users to post in what ever section they choose.
 
Moved to MT4 section.
Thanks for informing.
Reason: