MAIN QUESTION : Why getting "array out of range" error only when using "#property strict" ?
What the +3 mean? I have tried to understand it.
"while(i>=3)" means that we always need 3 bars in front? and fractals drawing for bar number 3 or more?
"i=Bars-nCountedBars+3" means that we want tell to indicator that always there is 3 un-checked bars , because it stop working if "i" equal to 0 ir i<3 ?
- With strict, bad references (negative or beyond maximum) results in an error. Without, the error is hidden and all you get is a zero.
- It means three.
if(dCurrent<Low[i+1] && dCurrent<Low[i+2] && dCurrent<Low[i-1] && dCurrent<Low[i-2] && Volume[i-3]>0)
The i-3 means you are looking 3 bars in the future (relative to i) If there aren't three bars there's nothing to access. By the way, you will never, ever, see a zero volume, (no tick, no bar.)i=Bars-nCountedBars+3;
Bogus. It is trying to make sure there are 3 bars in the past. See How to do your lookbacks correctly.-
Why did you post your MT4 question in the
Root /
MT5 Indicators
section
instead of the MQL4 section,
(bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. -
Start using the new Event Handling Functions.
Event Handling Functions - Functions - Language Basics- MQL4 Reference
- With strict, bad references (negative or beyond maximum) results in an error. Without, the error is hidden and all you get is a zero.
I dont understand your mean please answer MAIN QUESTION:
Why getting "array out of range" error only when using "#property strict" on this code?
whroeder1:
6. Start using the new Event Handling Functions.
Event Handling Functions - Functions - Language Basics- MQL4 Reference
Ok done. now check new code (first post edited) and tell me why still getting "out of range error" when using "#property strict" while it works fine without strict.
I dont understand your mean please answer MAIN QUESTION:
Why getting "array out of range" error only when using "#property strict" on this code?
Ok done. now check new code (first post edited) and tell me why still getting "out of range error" when using "#property strict" while it works fine without strict.
First you must understand why there is the strict directive in the first place. The early builds of MQL4 allowed some really dangerous errors to fly because code needed to be somewhat compatible with MQL3. With the "new" version of MQL4, MQ introduced more modern and "strict" code linting which checks the context so that metaeditor won't compile your source to bytecode if there are obvious errors. Along with strict linting it also will terminate a program not behaving correctly. This is important because when you don't use "strict" linting (compiling) then array out of range and other errors are allowed to pass silently which could result in some catastrophic side effects when real money is on the line. TL;DR You still have array out of range, but removing strict just allows it to pass silently (dangerously).
Thanks for help!
The problem solved by this code :
This code "if ((Bars-i)>=7)" mean it should not do anything for first 7 bars or more. because we need enough bars to calculate fractals. It should be the reason for strict mode failure . right?
for( i=limit-count; i>=3;i--) { if ((Bars-i)>=7) {
But the code was compiled without error. if the code has an error it should not be compiled . This bug need to be fixed in meta editor and errors should be shown .
But the code was compiled without error. if the code has an error it should not be compiled . This bug need to be fixed in meta editor and errors should be shown .
The compiler does a good job on picking up and warning about some sloppy coding.
Do you really expect it to check errors in execution while compiling?
Asked and answered. What part of "With strict, bad references (negative or beyond maximum) results in an
error. Without, the error is hidden and all you get is a zero." don't you understand?
Neither. If they do not access nonexistent elements, the result is the same with and without strict. Strict is trying to help you.
Always use strict. Fixing the warnings will save you hours of debugging, but you must understand the differences.
Neither. If they do not access nonexistent elements, the result is the same with and without strict. Strict is trying to help you.
Always use strict. Fixing the warnings will save you hours of debugging, but you must understand the differences.
So, you are saying that all of those codes should be rewritten to the strict mode?
Always use strict - and they don't use strict.
If the strict property is defined, they return array out of range.
I know your post where you show the new method of counting, and that works, but that requires to modify the code.
At the time those "old" codes were written there was no "strict" mode. It only came out later when the MQL4+ language update came out to make it more compatible to MQL5.
So, as long as the proper checks where done in the old MQL4 code, there is no need to have them rewritten.
It is going forward with the MQL4+ language available that one should always use "strict" mode, so as to help programmers write better more modern code.
- 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
This is a simple fractal indicator.
MAIN QUESTION : Why getting "array out of range" error only when using "#property strict" ?