But I always get "Array out of range" error. Maybe that's because I'm attempting to access the data of an indicator buffer while its size has not been initialized yet. But I don't know what to do.
Your code is completely mixed up and wrong! You are using the OnStart() event handler which is for Scripts, but then proceed to try to use code which is specific to creating new Indicators, while at the same time trying to access content for uninitialized dynamic arrays that have not yet been sized.
You are also mixing old MQL4 functions with new MQL4+ concepts! You are totally mixing apples and oranges!
So, either code an Indicator, and declare the Arrays as Indicator Buffers so that their sizes will be set properly ...
... or use a Script and properly size the arrays and don't use specialised functions that are meant to be used for creating new indicators.
Always lookup the documentation reference for the functions you use and look at the example code given. Don't just copy/paste code you find on the net without fully understanding how it all works.
If possible start with a book on coding MQL and follow the examples and learn things step by step.
Here are a few forum links about books to learn MQL:
- 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,
I'm trying to access the data of customer indicators I have "Aroon Up&Dn" and "MCAD" and get its Data in an array to do some checks on it later.
But I always get "Array out of range" error.
Maybe that's because I'm attempting to access the data of an indicator buffer while its size has not been initialized yet. But I don't know what to do.
Error occurs at the following line