Shut down Expert Advisor wehn closing a position

 

Hello

I would like my EA to shut down when the EA exit a position

Is that possible?

Cheers!

 

Lots of ways:

*Create a variable which exits the start() while true. When you exit a position, set that variable to true.

*Issue a mql4 un-friendly command like 1/0 (Zero-Divide).

Other more creative and better ways could be found by Searching the forum.

 
void RemoveEA() //Don't forget to use #include <WinUser32.mqh> for this function
{
  int h = WindowHandle(Symbol(), Period());
  if (h != 0) PostMessageA(h, WM_COMMAND, 33050, 0);
}

//found this in the forum somewhere
 

Thanks for the fast answer. I will try that.

Cheers!

 
Use this and you would have found this
Reason: