How do I programmatically stop an EA from trading? - page 2

Ray
2646
Ray  

I used to work for NEC. The topic was Telephone Central Offices -- and the required software/firmware to run such a beast

that might service up to 100,000 subscriber lines, interconnect with other local or long distance offices, maybe implement

Signalling System #7 and ISDN protocols.

One lesson I learned there was:

'Software is never complete. You just tell the Customer it is"

[Deleted]  

Hi guys,

the start() function is called at each tick.

now I can "stop" the EA by simply exiting start() before it got a chance to do anything else. however, this is not very safe. some condition (e.g. closing and re-opening mt4) might re-initialize the ea and it might "start" running again.

hence, there are situations where programmatically removing the ea might be a good idea. as far as i know, if this can be done at all, then only at the level of indows calls (winuser32.mqh & more).

gordon
2327
gordon  
arstrube:

the start() function is called at each tick.

now I can "stop" the EA by simply exiting start() before it got a chance to do anything else. however, this is not very safe. some condition (e.g. closing and re-opening mt4) might re-initialize the ea and it might "start" running again.

That's why all experts need a persistence layer. If done properly then expert will resume exact previous state - remain 'disabled'.

p.s. removal via WinAPI call -> https://www.mql5.com/en/forum/120736.

Jean-Jacques Juille
14
Jean-Jacques Juille  

Hello,

As I needed this information, I put the one I found.

To exit from an EA by programming in MT4, we can use the function :

ExpertRemove ()

Sample :

if (my_Exit_EA_Condition == true ) ExpertRemove();

After that if the OnDeinit () function exists, it is executed and the EA stops

Best regards.

-------------- En Français ---------------------------

Bonjour,

Comme j'ai eu besoin de cette information, je mets celle que j'ai trouvée.

Pour sortir d'un EA en programmant dans MT4, on peut utiliser la fonction:

ExpertRemove ()

Exemple :

if (my_Exit_EA_Condition == true) ExpertRemove ();

Après cela, si la fonction OnDeinit () existe, elle est exécutée et l' EA s’arrête

Salutations.