Features of the mql5 language, subtleties and tricks - page 204
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
No one has guaranteed that other event handlers will be interrupted (or not run).
After the alert, both deinit and init happen, right?
Yes, there is a complete reboot going on. It's just the timer (even a second one) that gets pounced on - a feature, not a bug.
This advisor alerts when switching between accounts. It would seem that it should not do this, according to the rule
This peculiarity can be used to solve a simple in formulation, but complex in implementation.
This feature can be used to solve a simple in formulation but complex in implementation.
Why can't we just check the account change at the input of each On-function?
Why a millisecond timer? It won't interrupt program execution anyway if a re-login occurs during the runtime.
Why can't you just check the account change at the input of each On-function?
Why a millisecond timer? It won't interrupt program execution anyway if a re-login happens while it's running.
Try it. There is a long discussion on this topic at the link above.
Yes, there is a complete reboot going on. It's just the timer (even a second timer) that gets bumped up - a feature, not a bug.
After the ExpertRemove() command the stop flag is simply raised and the EA continues to work until the next tick. On a new tick, the EA will be unloaded when the stop flag is raised. It means that until a new tick comes, all On-functions continue to work in the normal mode.
Accordingly, if we can't get the state of this flag programmatically (I haven't specifically looked for this feature), then we need to have a globally custom flag. We set our own flag before the ExpertRemove() command and check it in each On-function. If the flag is set, we will leave. Then the timer will not execute code that is written in it.
Or maybe I've got it wrong and the question is different?
After the ExpertRemove() command, the stop flag is simply set and the EA continues to work until the next tick. If the stop flag is raised on a new tick, the EA is unloaded. It means that until a new tick comes, all On-functions continue to work in the normal mode.
Accordingly, if we can't get the state of this flag programmatically (I haven't specifically looked for this feature), then we need to have a globally custom flag. We set our own flag before the ExpertRemove() command and check it in each On-function. If the flag is set, we leave. Then the timer will not execute code that is written in it.
Or maybe I've got it all wrong and the question is different?
I don't know what problem you're describing.
After the ExpertRemove() command, the stop flag is simply set and the EA continues to work until the next tick. If the stop flag is raised on a new tick, the EA is unloaded. It means that until a new tick comes, all On-functions continue to work in the normal mode.
Accordingly, if we can't get the state of this flag programmatically (I haven't specifically looked for this feature), then we need to have a globally custom flag. We set our own flag before the ExpertRemove() command and check it in each On-function. If the flag is set, we leave. Then the timer will not execute code that is written in it.
Or maybe I've got it all wrong and the question is different?
Not on a new tick, but on the next return;
Put ExpertRemove() in OnInit() and check it in the debug step by step.
Not on a new tick, but on the next return;
Put ExpertRemove() in OnInit() and check it step by step in debug.
Yes, my mistake. Any next event will not be executed. It's a long time since I've looked in help for functions I don't need :)
I don't know what problem you are describing.
The meaning of the answer is not clear. It doesn't matter.
The meaning of the answer is not clear.
ExpertRemove was not invoked.