Hi,
I am trying to use a MovingAverage[10] (or anything over 3) in the Copybuffer:
The error is when calling MABigOne[10] (Or any other value above 3).
I have read the documentation and having the same issue for over a year however do not understand it, I am sure there is a simple way to get this to work.
I have tried using this concept in several other EA's but never resolved it, so simply use 3 candles only for systems.
Error shown below
2021.12.29 08:30:35.652 Core 1 2021.08.13 00:00:00 array out of range in 'BoosterPlan.mq5' (111,23)
There are several of these articles in the forums all directing to documentation (great but I do not understand the actual fix). If anyone can point out the changes it would be greatly appreciated and will likely save this topic being brought up over and over.
Change
MABigOne[10]
to
MABigOne[9]
Correct your gross mistake - you create an indicator handle at every tick! Remember: according to the MQL5 style, the indicator hand MUST be created ONCE and you MUST do it in OnInit!
Hi,
I am trying to use a MovingAverage[10] (or anything over 3) in the Copybuffer:
...
2021.12.29 08:30:35.652 Core 1 2021.08.13 00:00:00 array out of range in 'BoosterPlan.mq5' (111,23)
There are several of these articles in the forums all directing to documentation (great but I do not understand the actual fix). If anyone can point out the changes it would be greatly appreciated and will likely save this topic being brought up over and over.
I am trying to use a MovingAverage[10] (or anything over 3) in the Copybuffer:
The error is when calling MABigOne[10] (Or any other value above 3).
When defining an Array[10] you are basically saying 'this array is supposed to have ten fields.' That is 0-9 which means when you are trying to access this array with the index 10 it will give you an out of range error because you would need 11 fields to be able to work with indizes 0-10. Not sure why it shouldn't work with more than three.
When defining an Array[10] you are basically saying 'this array is supposed to have ten fields.' That is 0-9 which means when you are trying to access this array with the index 10 it will give you an out of range error because you would need 11 fields to be able to work with indizes 0-10. Not sure why it shouldn't work with more than three.
Hi pennyhunter,
Thank you for your comment, I changed my array to one less than the copy buffer and it works above 3 now. Not sure why 3 was working as 3 in copybuffer and 3 in the array call though.
The code seems to be working now, using the bigger array numbers. Thanks again! Very helpful.
Correct your gross mistake - you create an indicator handle at every tick! Remember: according to the MQL5 style, the indicator hand MUST be created ONCE and you MUST do it in OnInit!
Thank you Vladimir,
I have not put the indicators in an OnInit, with the copybuffer and array calls in the OnTick. It seems to be working as it should.
Will this make my code run smoother/faster/easier?
What is the purpose of this as it was working as planned when running OnTick?
Your help has been much appreciated!
Thank you Vladimir,
I have not put the indicators in an OnInit, with the copybuffer and array calls in the OnTick. It seems to be working as it should.
Will this make my code run smoother/faster/easier?
What is the purpose of this as it was working as planned when running OnTick?
Your help has been much appreciated!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am trying to use a MovingAverage[10] (or anything over 3) in the Copybuffer:
The error is when calling MABigOne[10] (Or any other value above 3).
I have read the documentation and having the same issue for over a year however do not understand it, I am sure there is a simple way to get this to work.
I have tried using this concept in several other EA's but never resolved it, so simply use 3 candles only for systems.
Error shown below
2021.12.29 08:30:35.652 Core 1 2021.08.13 00:00:00 array out of range in 'BoosterPlan.mq5' (111,23)
There are several of these articles in the forums all directing to documentation (great but I do not understand the actual fix). If anyone can point out the changes it would be greatly appreciated and will likely save this topic being brought up over and over.