automaticly stop the EA if the equity is less than a predeterminded value.

 

Hi,

Could anyone tell me, is there a way to automatically stop the EA if the equity is less than a predetermined value. Is there a bulit-in function in MT5

 

There isn't such an option in the MT5 terminal.

You may search the Market and Codebase, or order such a program in Freelance.

Recommendations about products are not allowed in this forum.

 
Thomas19890620:

Hi,

Could anyone tell me, is there a way to automatically stop the EA if the equity is less than a predetermined value. Is there a bulit-in function in MT5

check ExpertRemove() function.

https://www.mql5.com/en/docs/common/expertremove

Documentation on MQL5: Common Functions / ExpertRemove
Documentation on MQL5: Common Functions / ExpertRemove
  • www.mql5.com
ExpertRemove - Common Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Yashar Seyyedin #: check ExpertRemove() function.

That won't work externally, only the EA can remove itself.

 
Yashar Seyyedin #:

check ExpertRemove() function.

https://www.mql5.com/en/docs/common/expertremove

With this approach, the ExpertAttach() function would be required to return the expert to the chart when the equity again become greater than the value from the settings😄

Thomas19890620:

Hi,

Could anyone tell me, is there a way to automatically stop the EA if the equity is less than a predetermined value. Is there a bulit-in function in MT5

  • If you have the source code of the EA that you want to stop, then you need to make changes to it. Namely, check equity before sending trade requests.
  • If you do not have the source code, then it is much more difficult, but still implementable. But anyway, this option is worse than changes to the source code of the adviser
 
 void OnTick()
{

double MaxDrawDown = 5 ;

   if(((1-(AccountEquity()/AccountBalance()))*100)>MaxDrawDown)
     {
     //here you can put any order like delete PendingOrder or CloseBUY or CloseSELL
     }
}
Reason: