Download MetaTrader 5
To add comments, please log in or register
Create Forum topics and improve your rating!
Luciano Ola
996
Luciano Ola 2014.02.27 20:45 

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.

whroeder1
13596
whroeder1 2014.02.27 21:29  

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--){
:
Ian Venner
2583
Ian Venner 2014.02.28 02:10  

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 ;)

Luciano Ola
996
Luciano Ola 2014.02.28 10:24  
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.

qjol
3243
qjol 2014.02.28 10:27  
our code works just fine for me
hops there is no code
Luciano Ola
996
Luciano Ola 2014.02.28 10:30  
Lol looks like it was my array calc, fortunately I had fixed a similar issue with another array earlier thanks to a thread I read on this forum, so find the issue this time wasn't as hard.
qjol
3243
qjol 2014.02.28 10:36  

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

Luciano Ola
996
Luciano Ola 2014.02.28 10:57  
qjol:

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?
Alain Verleyen
Moderator
28522
Alain Verleyen 2014.02.28 11:22  
MetaNt:

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.
Luciano Ola
996
Luciano Ola 2014.02.28 12:18  
angevoyageur:
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.
/
To add comments, please log in or register