Beta version of the online book on MQL4 programming - by Sergey Kovalev (SK.) - page 10

 
Sorry, found it!
Yes, the manual is really cool, but going back to my earlier request - it needs to be on hand to be able to look up promptly.
Ideally - it should replace the standard help in new versions of MT.
 

to SK

double my_search_and_etc()
{ double summ[]; //array within the function
//.........
i=ArrayMinimum(summ,iter,0); // tracer: <incorrred start position 0 for ArrayMinimum function>

//second error variant
static double summ[]; //
//.........
i=ArrayMinimum(summ,iter,0); // tracer: <incorrred start position 0 for ArrayMinimum function>
//i.e. Error of dynamic addressing of the initial element of the array on the second tick
//.......................

//........................
//right time
double summ[1000]; //specifying of explicit size implies type static
//.........
i=ArrayMinimum(summ,iter,0); // O.k.
//right two
static double summ[1000]; //reinsurance to explicit size
//.........
i=ArrayMinimum(summ,iter,0); // O.k.
}

 
No, you don't need to replace the standard help. Keep it. Normal language software developers separate the language description from all the various tutorials for it.
 
Korey:

to SK


I'm not quite sure what your question is. Is the set of strings you've provided a complete code (then why is the initialization repeated?) or scrappy strings (then why are there curly braces?). Submit the finished code and formulate the question. Use the MQL button (on the top line of the edit window) to publish the code.
 
Renat:
Congratulations to Sergei Kovalev!

The release of the MQL4 Tutorial is scheduled for February 1, and it has already been integrated into the MQL4.community website. The translation into English is well under way.

Thank you for your congratulations, Renat.

I would like to take this opportunity to tell you once again that it is a great honor for me to publish the MQL4 tutorial on MetaQuotes Software Corp. website. I sincerely thank you for your trust, support and encouragement. I also thank Stanislav Starikov and Rashid Umarov from MetaQuotes Software Corp. for their valuable advice and help in the preparation of the textbook.

 
to SK
The article shows 4 variants of array initialization with one and the same call ofArrayMinimum();
It is shown that initializing an array in a subprogram without specifying the array's size [] leads to the "RunTime" error
- first two variants, the error is quoted, in translation: "incorrect ADDRESS of the beginning of the array."
-second two variants are working, it is shown that specifying a dimensionality of [1000] automatically makes the array static.
Conclusions:
1) MQL4 arrays are not always static,
2) definition of static a[], i.e., without explicit dimensionality, will not work, but there will be no error message. The error is displayed at runtime on the second and subsequent tick in the Expert Advisor window.
3) Described errors of static/dynamics appear if the array is defined in the sub/func, and are caught only by those who looks in the "Expert Advisors" window,
and only when second tick comes. For example, the error is not detected when debugging the indicator at the weekend without using the strategy tester.
4) The textbook line "MQL4 arrays are always static" may be related to earlier builds.
 

I would like to have a set of video tutorials in addition to the text tutorials. Have a set of video tutorials. Especially lacking is one very first lesson - how to download, install the programme and make the first Buy or Shell trade.

 
Korey:
to SK
The article shows 4 versions of initialization of an array with one and the same call ofArrayMinimum();
It is shown that initializing an array in a subprogram without specifying the array's size [] leads to the "RunTime" error
- first two variants, the error is quoted, in translation: "incorrect ADDRESS of the beginning of the array."
-second two variants are working, it is shown that specifying a dimensionality of [1000] automatically makes the array static.
Conclusions:
1) MQL4 arrays are not always static,
2) definition of static a[], i.e., without explicit dimensionality, will not work, but there will be no error message. The error is displayed at runtime on the second and subsequent tick in the Expert Advisor window.
3) Described errors of static/dynamics appear if the array is defined in the sub/func, and are caught only by those who looks in the "Expert Advisors" window,
and only when second tick comes. For example, the error is not detected when debugging the indicator at the weekend without using the strategy tester.
4) The textbook line "MQL4 arrays are always static" may be related to earlier builds.


Your reasoning is not very clear. You declare a dimensionless array (in fact, the program has only the name of the array, the elements of which are not defined and for which no memory is allocated), and try, using the ArrayMinimum() function, to find the minimum value among the elements that don't exist. Of course, the error will occur regardless of whether the array is declared as static or not, and you should treat the execution error as an indication of the array's property to be static or not.

Arrays in MQL4 are static by definition. It means (unless, of course, there is at least one element in the array) that the array elements are stored from the last time the function (which declared the array) was terminated until the next time it is called, regardless of whether or not the array identifier has the static keyword in front of it.

 
to SK
What do I care, we have been using these memory allocation tricks for a long time.
I wrote not about contents of the array, but about its addressing, that there are no compilation errors, no linking errors, but there is an ADDRESS PRINTY ERROR.
That is, the compiler allowed me to define an array [] in a subroutine to grow it later, - that's good (!),
it's dynamic memory allocation by array.
However, all pointers to this array are linked as direct pointers (but not pointers to pointers),
which leads to a mismatch between the linked static addresses and the newly allocated array address when dynamic memory allocation follows.
I.e., the array (pointer) reference in MQL4 is now static, and it works correctly only when the array is really static.
The compiler doesn't understand that the array will be moved in the future without the explicit size inside the subroutine.
Programmer puts static and thinks everything is correct, but if he doesn't specify an explicit size - no static array, and the array will actually turn out to be dynamic (no compilation/loading errors).
The problem is not that big, usually everyone keeps arrays at global level.
But it is desirable to write in the tutorial not that supposedly all arrays are already static, but that you should write local arrays static with an explicit size.
 
Korey:
to SK
Programmer puts static and thinks everything is correct, but if he does not specify an explicit size - no static array, and the array will actually turn out to be dynamic (no compilation/loading errors).

A programmer who knows that all arrays in MQL4 are static will not put static, simply because it is not necessary.

But it is desirable to write in the tutorial not that supposedly all arrays are already static, but that local arrays should be specified as static with an explicit size.

Perhaps you have confused the concepts. In this case, "static" means the property of storing values of array elements in the interval between executions of the function in which it is declared. Arrays always preserve their values during this time, regardless of the fact that they have static in front of the name (this is not true for local variables, though; they need to be explicitly declared as static).

It's possible, however, to resize an array in the first dimension with ArrayResize().

Reason: