Is it a good practice to set a random large size for your arrays,
I'm converting an indicator from mt4 to mt5, the code compiles with 0 warning ⚠️ and 0 errors. But the expert tab screens array our of range.
I don't seem to understand exactly what's wrong. What's your advice on this
Files:
IMG_20230226_193727.jpg
4294 kb
- Array out of range error
- Array out of range. But why?
- Error Array out of range in an custom indicator
Fela Fomonyuy: Is it a good practice to set a random large size for your arrays,
I'm converting an indicator from mt4 to mt5, the code compiles with 0 warning ⚠️ and 0 errors. But the expert tab screens array our of range.
I don't seem to understand exactly what's wrong. What's your advice on this
No! The good practice is properly identifying the indexing range for arrays. And in the case of non-buffers, to correctly sizing them as required.
EDIT: If you need further guidance, show your code.
Attached below is the code file
And a screenshot of the specific line
Files:
177_095854.PNG
38 kb
chart.mq5
20 kb
"Array out of range" is a Runtime error when an Array created then you called that Array out of it's 'index'. So if your all Syntaxes are ok then there will be no 'Compilation Error'. So carefully check your all Arrays/Buffers where you called it out of index. Example, you declared an array where it's size is 10. So you can call this array start from 0 to 9. If you call index below 0 or above 9 then you'll get Array out of range error.
Mahadi Hasan Razu #:
"Array out of range" is a Runtime error when an Array created then you called that Array out of it's 'index'. So if your all Syntaxes are ok then there will be no 'Compilation Error'. So carefully check your all Arrays/Buffers where you called it out of index. Example, you declared an array where it's size is 10. So you can call this array start from 0 to 9. If you call index below 0 or above 9 then you'll get Array out of range error.
Let me check through
"Array out of range" is a Runtime error when an Array created then you called that Array out of it's 'index'. So if your all Syntaxes are ok then there will be no 'Compilation Error'. So carefully check your all Arrays/Buffers where you called it out of index. Example, you declared an array where it's size is 10. So you can call this array start from 0 to 9. If you call index below 0 or above 9 then you'll get Array out of range error.
Fela Fomonyuy #:
Let me check through
Let me check through
Fela Fomonyuy #:
Let me check through
Just a follow up. I did notice after some research, resizing the arrays fixed the runtime error but another issues is up. The indicator is removed from the chart after a few seconds. It doesn't throw any error message. After a few seconds it's removed from the charts.
Let me check through
Files:
problem.PNG
100 kb
compiled.PNG
97 kb
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register