for (int i=limit; i>=0; i--) if(close[i]> close[i+1]) // close[i+1] is out of range.
In MT4, buffers and the predefined arrays are all ordered AsSeries. There is a difference between the arrays passed to OnCalculate (e.g. low[]) and the MT4 predefined variables (e.g. Low[].) The passed arrays have no default direction, just like MT5.
To determine the indexing direction of time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[], call ArrayGetAsSeries(). In order not to depend on default values, you should unconditionally call the ArraySetAsSeries() function for those arrays, which are expected to work with.predefined variables (e.g. Low[].) The passed arrays have no default direction, just like MT5.
Event Handling Functions - Functions - Language Basics - MQL4 Reference
- 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 wanted to convert the following MQL4 Indicator to MQ5. Unfortunately, the compiler spits the error message: ARRAY OUT OF RANGE. The error message refers to the following line in the OnCalc(): " if(close[i]> close[i+1]) ". I do not quite understand the program logic of MQL4, which is why I can not interpret the error. However, I suspect that I somehow have to work with the ArraySetassSeries () function.
MQ5 Approach:
The original mq4 Version:
I would appreciate your Help :)