To stop EA after fixed profit percentage over starting balance.

 

i want to stop expert advisor to trade after fixed profit target over account initial balance.

i built EA for my prop firm account. this is the code i entered  after my startegy .


when i started backtesting , the EA still continues to trade.

double floatingprofits ;
input int startbalance = 50000;
input double reqprofitspercenge =  9;


int OnInit()
  {
//--- 
 
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//// After all my trading strategy and trade orders ////

  floatingprofits = AccountInfoDouble(ACCOUNT_PROFIT);
  
  double aftertradeprofits = floatingprofits / startbalance * 100;
 
  if ( aftertradeprofits >= reqprofitspercenge) {
  ExpertRemove();
  }
      
   
  }
//+------------------------------------------------------------------+
 
DEEPAK SONI:

i want to stop expert advisor to trade after fixed profit target over account initial balance.

i built EA for my prop firm account. this is the code i entered  after my startegy .


when i started backtesting , the EA still continues to trade.

Your profit reached 4,500 ?
 
Alain Verleyen #:
Your profit reached 4,500 ?
Yes , it goes above 58000 and keeps on trading.i created upon my day trading strategy wid trailing stoploss to control drawdown below 4% 
 
Alain Verleyen #:
Your profit reached 4,500 ?
This is one of its backtesting
Files:
image_c2o.png  197 kb