Features of the mql5 language, subtleties and tricks - page 159
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
Can you tell me please, pls.
In indicator the order of series, e.g. close[], is set by ArraySetAsSeries() once or in some other way ?
Is it done in OnCalculate() or can it be done in OnInit() ?
I've encountered a confusing situation:
Order in close[], set by AS_SERIES on entry on first tick, on next tick spontaneously changes to normal, i.e. !AS_SERIES.
I haven't found the reason for this in the code.
in any function getting scalar &arr[] you cannot be absolutely sure about the array indexing direction :-(
Moreover, if you change the "seriality" inside, this direction will remain after your function ends...it will be a side-effect, which no one expects
that's why, unfortunately, when you get an array for input into a function, remember its serialization, set it to a convenient one and ALWAYS return the original back when you exit the function
This is a rare case with OnCalculate, but in practice it used to be called from other code as well.
Moreover, if you change "serialisation" internally, this direction will remain when your function ends...
That's what I was counting on. That's why I putArraySetAsSeries(close,true) inOnCalculate() block, which is executed only once at first login. And this "serialization" was indeed set. However, to my surprise, on the second tick, and beyond, the "seriality" was already the opposite.
With OnCalculate it's a rare case, but in practice it happened to be called from other code as well.
I don't have such exotics and, moreover, I don't change the "serialization" of timeseries and buffer arrays inside the program. Therefore, it would be enough for me to set it once, at the beginning of the indicator. But, if we cannot be sure that the "seriality" of these arrays is saved, we have to set it at the beginning of each OnCalculate() loop. This seems to be something completely unnatural.
It is a good idea to generate a warning at compile time.
If nothing has changed since the old days, NULL != "" Many people have fallen for this before.
If nothing has changed since the old days, NULL != "" Many people have fallen for this before.
That's not what we're talking about.
We are talking about something else.
Then explain why it can't be. Why
can be, but
it can't be.
Then explain why it can't be.
The script above shows this.
The above script shows this.
If it did, there would be no questions. You always think that everyone around should read your mind, or be better trained than you in programming.
If it did, there would be no questions. You always think that everyone should read your mind, or be better trained than you in programming.
I don't understand the reasons for this reaction. The terse code demonstrates the feature 100%.
I don't understand the reasons for this reaction. The terse code demonstrates the feature 100%.
Normal reaction. I don't understand your codes, I asked for an explanation, and the answer is...
NULL is such an ambiguity that you have to deal with it carefully. Especially when applied to string variables.
From the documentation
Hence, in this example NULL does not mean that the string length is equal to zero, but that the variable is not initialized.
In your example
the variable is initialized. It is not clear to me how it is initialized and I don't feel like sorting it out.
Consequently,
Indicates that the variable is initialized. Again, with what is the big question. Why do you think it is impossible to initialize a variable by NULL?
Apparently this initialization causes the string length to be equal to zero, which is what this check says about