string candles_array[5]; ⋮ for(int i = 1; i <= 6; i++){ //looping over the past 6 candles DetermineCandle(i-1);
- The array has five (5) elements; their indexes are [0 … 4]. When i equals six (6), DetermineCandle is called with five (5). It tries to update the array[5], array exceeded.
-
Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)
- The array has five (5) elements; their indexes are [0 … 4]. When i equals six (6), DetermineCandle is called with five (5). It tries to update the array[5], array exceeded.
-
Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)
Oh I see, thanks a lot!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone! I'm new to MQL5 programming and have been struggling with this issue for a while. I tried everything but couldn't get from point A to point B. Essentially, I want to loop through the previous six candles and add them to an array. However, I always get an array out of range error. I just don't get why. Can anyone lend me a hand? It would be really appreciated.