How to exit properly from a EA?

 

Hello,

How to exit properly from a EA?

Regards,

Pierre8r

 
You don't, an EA runs and runs and runs . . . there are workarounds to take the EA off the chart from code, use the search, but I don't consider it to be "exit properly" as I don't consider that there can be such a thing.
 
tintin92:

Hello,

How to exit properly from a EA?

Regards,

Pierre8r


Remove EA close all (or delete "pending") trades opened by the EA
 
RaptorUK:
You don't, an EA runs and runs and runs . . . there are workarounds to take the EA off the chart from code, use the search, but I don't consider it to be "exit properly" as I don't consider that there can be such a thing.


Thanks RaptorUK.

Pierre8r

 
tintin92:


Thanks RaptorUK.

Pierre8r

Maybe I misunderstood your question though . . .
 
RaptorUK:
Maybe I misunderstood your question though . . .


No, you don't.

It's a useful answer.

It's a sincere thanks.

I need a "exit properly", not a workarounds.

If there are no "exit properly", I will live without it.

Pierre8r

 
tintin92:


No, you don't.

It's a useful answer.

It's a sincere thanks.

I need a "exit properly", not a workarounds.

If there are no "exit properly", I will live without it.

Pierre8r


"I will live without it" does that mean in this case you leave the EA run and do nothing because workarounds is not what you need if there is no other solution ??

or do you have to do what i was suggesting.... You simply have to make it the EA is not allowing to open again the type of trades that are closed just before

So Maybe I misunderstood your question though . . . and didn't you like it that i answer the question my way...

 
tintin92:
How to exit properly from a EA?
You could add an external, Right click -> expert properties. Change it and have the EA close its orders and exit.
extern bool EA.Exit = false;
:
#define MT4_WMCMD_REMOVE_EXPERT   33050
#include <WinUser32.mqh>       
int start(){
   if (EA.Exit){
      CloseAllOrders();
      // this will remove expert from chart
      if (!IsStopped())  // https://forum.mql4.com/32837 WH can deadlock
      PostMessageA( WindowHandle( Symbol(), Period()), WM_COMMAND, MT4_WMCMD_REMOVE_EXPERT, 0);
   }
   :
}
How do I close an Expert programmatically? - MQL4 forum
Reason: