I have an mql4 indicator code but i wanted to convert into mql5. I changed the old start() -> OnCalculate(), solve all the time,Bars,High,Low function but i think missed some array modification because i get all the time "Out of Array " error and i don't know what i missed, because the same code is working on the mt4 without any problem. The redline and probably all the arrays the problem.
Before The OnCalculate function in the OnInit I set the buffers and set the Arrays free.
What was I missed? Thanks for your Helping.
- if it is interesting for them personally, or
- if it is interesting for many members of this forum.
Freelance section of the forum should be used in most of the cases.

- 2024.10.14
- www.mql5.com
Maxh and MinL should be PRICE_HIGH and PRICE_LOW, not "MODE", correct?
EDIT: personally -- i would change the iHigh and iLow to use high[i] and low[i], instead -- after adding set as series for these 2, AND adding them as Calculation buffers in OnInit.
Hi
iHigh and iLow functions are not working the same way in MT4 and MT5, you need to convert them or as was suggested use high [] and low [] arrays to get the values. There might be also other issue with setting the buffers since it’s quite different approach in the mt5 than in mt4. You can find a similar indicator and see how it should be done and then try to convert our indicator the same way.
Have a nice day👍📊
Hi, I've taken a look at your code and I think I can help you out. I've successfully converted the indicator from MQL4 to MQL5 and it's working as expected. The main differences between the two languages are indeed the changes you mentioned (start() -> OnCalculate(), Time, High, Low functions), but also the array handling.In MQL5, arrays are declared with a fixed size, whereas in MQL4, they can be dynamic. This means that you need to specify the size of the array when declaring it in MQL5. I've updated the array declarations in your code to match the MQL5 syntax.Additionally, I've also updated the code to use the correct array indices, as the MQL5 compiler is more strict about array bounds checking.
I have attached the mq5 file below. Let me know if you need any help.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Before The OnCalculate function in the OnInit I set the buffers and set the Arrays free.
What was I missed? Thanks for your Helping.