Features of the mql4 language, subtleties and techniques - page 5

 
Artyom Trishkin:

I can't check right now, but MQL_TESTER seems to include everything else. But everything else separately does not include each other.

That is, to understand that the program works in the tester (in any of listed modes), you only need to check the very first flag.

The example was about something else.
 
fxsaber:
The example was about something else.
Then I didn't get it - what was it about?
 
Artyom Trishkin:
Then I don't understand - what is it about?
static const is initialised by a function.
 
fxsaber:
static const is initialised by a function.
Ahhhh ..., "...Semyon Semyoyonych"... (с)
 
fxsaber:
The static const is initialized by a function.

1. Where in the program is this located?

I assume it's in the area of global variables. Not to mention that global variables don't need static modifier, the initialization sequence plays a very important role.

My level of programming professionalism is much lower than yours, so I conduct some experiments of the level you do not even think about... Supposedly.

So here is the initialization sequence: (for those who don't know about it)

First, global-level variables, then static ones, depending on the priority of functions, OnInit(), OnTick() or OnCalculate()... I wasn't interested in further, and I was not interested in local ones in my time. So it turns out in this code that the function is called before the static variables are initialized, hence the error we are speaking about. The function is called before the stInt variable is initialized.

2. At the beginning of this branch, we were talking about closing orders by price OrderClosePrice(), do you remember? It also works, but we may run into trouble. It is the same in this case, too.

That's why there is no such feature in the help. So that when you write your d***-code you don't get flooded with complaints that things stated in the documentation don't work. You know how many of these programmers are present here. And how many inadequates have been banned for life? Again, presumably...

 
Alexey Viktorov:
Apparently, you read something between the words of a single phrase

Forum on trading, automated trading systems and trading strategies testing

Features of mql4 language, subtleties and tricks

fxsaber, 2017.04.29 10:54

On the subject of static, there is such a subtle point in both languages

There is no hidden implication in this phrase.


As for the example, it works either way.

 
fxsaber:
You must have read something between the words of the single phrase

There is no hidden implication in this phrase.


As for the example, it works either way.

Well, there' s a link with an example of code with an error in addition to your phrase. My reply was not to your phrase, but to that incorrect code, which is exactly the g***-code.

I have no doubts that your code sample works.

 
Alexey Viktorov:

So there' s a link with an example of code with an error in addition to your phrase.

There is the word "subtlety" in the thread title. That code is a demonstration of subtlety.

I don't see any reason why developers cannot make this code work - what the author wanted to see. Whether they do or not, that's his application to the SD. But the example itself is illustrative.

 
fxsaber:

There is the word 'subtlety' in the branch title. That code is a demonstration of subtlety.

I don't see any reason not to let the developers make that code work - which is what the author wanted to see. Whether they do or not, that's his application to the SD. But the example itself is illustrative.

It started to refer to subtlety after our dialogue. And before it was like an error message. Only it cannot be called a mistake.

Do you have a suggestion how to change the initialization sequence to make this code work as you want it to? Somehow it seems to me that this request will hang without any response.

 
Alexey Viktorov:

It started to refer to subtlety after our dialogue. Before that, it was like an error message. Only you can't call it an error in any way.

If it had been a mistake, a different thread would have been chosen. Moreover, reposting wouldn't even have happened, as the application is hanging in the SD. It's exactly a subtlety that's useful to know about.

Any suggestion on how to change the initialization sequence to make such code work the way you want it to? For some reason it seems to me that this application will hang unanswered.

Not a programmer. I assume this code works in C++.
Reason: