Why my command execute after ExpertRemove()

 

Hi guys,

I'm confused why this happens?

void deinit()
{}

void start()
{
        ExpertRemove();
        Comment("Hi Hossein");
}


By this code I receive the comment "Hi Hossein", however it is after ExpertRemove()!
Why my code even work after ExpertRemove function?
please note there is no code in deinit function.

Any advice is appreciated.

 
ExpertRemove();

if (!IsStopped())
  Comment("Hi Hossein");
 

Hi,

in the MQL-Reference you can read this:

The Expert Advisor is not stopped immediately as you call ExpertRemove(); just a flag to stop the EA operation is set.

That is, any next event won't be processed, OnDeinit() will be called and the Expert Advisor will be unloaded and removed
from the chart.

I think, this answers your question.

Best regards

 

Please learn to read the documentation. It will only be removed once your return from the current event handler.

"The Expert Advisor is not stopped immediately as you call ExpertRemove(); just a flag to stop the EA operation is set. That is, any next event won't be processed, OnDeinit() will be called and the Expert Advisor will be unloaded and removed from the chart."

Also, please don't use the old almost obsolete MQL4 code. Us the new modern MQL4+ event handlers such as OnInit(), OnTick() and OnDeinit().


Event Handling Functions - Functions - Language Basics - MQL4 Reference
Event Handling Functions - Functions - Language Basics - MQL4 Reference
  • docs.mql4.com
Event Handling Functions - Functions - Language Basics - MQL4 Reference
 
Werner Klehr:

Hi,

in the MQL-Reference you can read this:

The Expert Advisor is not stopped immediately as you call ExpertRemove(); just a flag to stop the EA operation is set.

That is, any next event won't be processed, OnDeinit() will be called and the Expert Advisor will be unloaded and removed
from the chart.

I think, this answers your question.

Best regards

It says "any next event won't be processed" but my Comment processed after it!

 
HosseinKOGO:It says "any next event won't be processed" but my Comment processed after it!
"Event" is not the same as function. "Events" are things like a new tick for OnTick() or a time event for OnTimer().
 
Fernando Carreiro:
"Event" is not the same as function. "Events" are things like a new tick for OnTick() or a time event for OnTimer().
Oh so after ExpertRemove function, it processes all the code after it for that specific tick? and not for the new tick right?
 

Hi,

of course, "any next event won't be processed" means, that no further events will be processed.
But the Comment is a statement in the same event.

Hope this helps you.

Best regards


... I see Fernando has explained it while i was typing :-)

 
HosseinKOGO: Oh so after ExpertRemove function, it processes all the code after it for that specific tick? and not for the new tick right?

Yes! It will only be removed once your return from the current event handler.

 

Thank you all guys.

Greatly appreciated!

 
HosseinKOGO: Thank you all guys. Greatly appreciated!
You are welcome!