Need code to make EA stop live trading if a specified relative drawdown has been reached

 

Hi,


I am struggling on how to implement a function into my EA that makes it stop live trading once a certain relative drawdown from the equity high(!) has been reached. So say it has achieved 1000 EUR NetProfit and now a drawdown of 400 Euro happens from that equity high of 1000 EUR, I want to make it stop live trading.


It´s not the problem to implement the function of making it stop once this condition has been made, but rather how to calculate the relative drawdown from the equity high of the EA that it has reached in live trading.


Any ideas/code for this would be much appreciated. Thank you very much.

 
Start with current account balance. Go through history and subtract (profit-commissions-swap.) Remember the highest result.
Reason: