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);
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

- 2016.04.21
- www.mql5.com
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).
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.
-
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 -
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 - Don't assume that index for the current chart is the same on other charts; use iBarShift.
Thanks for informing.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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);