Old Mt4/non-strict out of range array references silently returned zero. New Mt4/strict returns an error. https://docs.mql4.com/en/mql4changes
Your indicator is not fine, you should fix it. Probably not adjusting for lookback
int counted = Indicator_Counted(); if(counted < LOOKBACK) counted = LOOKBACK; for(int iBar = Bars - 1 - counted; iBar >= 0; iBar--){ :
A lot of older indicators would fail in strict mode for that same reason. Indicator coders have to tighten up ! The old, "well... thats the other end of the chart, no one will notice that mess" type of coding wont cut it in strict mode ;)
int counted_bars=IndicatorCounted(); if(counted_bars<0)return(-1); if(counted_bars>0)counted_bars--; int uncountedbars=Bars-counted_bars;
Is what I use.
I think it might be to do with my array calc itself, which is annoying because I've tried to fix that part for strict mode and it didn't work.
hops there is no code
read the documentation
Old MQL4 compiler |
New MQL4 compiler |
New MQL4 with #property strict |
"Array out of range" does not cause a critical error |
Ditto, except for the arrays of structures and classes, for which this error is critical one |
"Array out of range" is a critical error causing the program to stop |
read the documentation
Old MQL4 compiler |
New MQL4 compiler |
New MQL4 with #property strict |
"Array out of range" does not cause a critical error |
Ditto, except for the arrays of structures and classes, for which this error is critical one |
"Array out of range" is a critical error causing the program to stop |
So is an array out of range a critical error in general, or is the strict property too strict?
So is an array out of range a critical error in general, or is the strict property too strict?
An array out of range results always from a bad coding. The compiler can/cannot catch it according to the use of #property strict.
Right ok thanks, well I've fixed it now, thank God.
![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
When I use strict mode I get an array out of range error and my indicator is not drawn correctly, when I do not use strict mode no error is received and my indicator is fine.
Is strict mode needed in most cases?
Why would I receive an error in strict mode and not in non strict mode?
Answers would be much appreciated.