• Join us

How to exit properly from a EA?

To add comments, please log in or register
Pierre Rougier
396
Pierre Rougier  

Hello,

How to exit properly from a EA?

Regards,

Pierre8r

Simon Gniadkowski
17226
Simon Gniadkowski  
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.
Tjipke de Vries
6647
Tjipke de Vries  
tintin92:

Hello,

How to exit properly from a EA?

Regards,

Pierre8r


Remove EA close all (or delete "pending") trades opened by the EA
Pierre Rougier
396
Pierre Rougier  
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

Simon Gniadkowski
17226
Simon Gniadkowski  
tintin92:


Thanks RaptorUK.

Pierre8r

Maybe I misunderstood your question though . . .
Pierre Rougier
396
Pierre Rougier  
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

Tjipke de Vries
6647
Tjipke de Vries  
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...

William Roeder
20430
William Roeder  
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
To add comments, please log in or register