Stop and Exit EA when Equity has increased by $ amount. - page 2

 

Please use Equity Guard. It will serve your purpose here. 

 
KashifNawaz:

Please use Equity Guard. It will serve your purpose here. 

//+------------------------------------------------------------------------+
//| Closes everything
//+------------------------------------------------------------------------+
void CloseAll()
{
  string symbol = Symbol();

  for(int i=OrdersTotal()-1;i>=0;i--)
  //for(int ii=0;ii<OrdersTotal();ii++)
 {
       bool result=false;
       if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
       if((OrderMagicNumber()!=Magicsell || OrderMagicNumber()!=Magicbuy) && OrderSymbol() != symbol) continue;
    //double result;
        if ( OrderType() == OP_BUY)  result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
        if ( OrderType() == OP_SELL)  result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
        //if ( OrderType()== OP_BUYSTOP)  result = OrderDelete( OrderTicket() );
        //if ( OrderType()== OP_SELLSTOP)  result = OrderDelete( OrderTicket() );
        
        
       if(result)i++;
 }
  return;
}


//+------------------------------------------------------------------+
//| profit/loss open buy                                             |
//+------------------------------------------------------------------+
int profitopenbuy()                       
{
   double totalopenbuy=0;                       
   int i;                              
   for(i=0; i<OrdersTotal(); i++)      
                                      
   {
       //double resultsell2=0;
       //double resultsell3=0;
       if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
       if(OrderMagicNumber()!=Magicbuy  && OrderSymbol() != Symbol()) continue;
      
       //if(OrderProfit()<0) resultsell2 = OrderProfit();
       //if(OrderProfit()>0) resultsell3 = OrderProfit();

       if (OrderType() == OP_BUY && OrderMagicNumber()==Magicbuy)  totalopenbuy = totalopenbuy+OrderProfit();
       //if ( OrderType() == OP_SELL && OrderMagicNumber()==Magicsell) totalopenbuy = totalopenbuy+OrderProfit();

       //totalsell++;                         // count if matched
   }
   return(totalopenbuy);                      

}
//+------------------------------------------------------------------+
//| profit/loss open sell                                            |
//+------------------------------------------------------------------+
int profitopensell()                       
{
   double totalopensell=0;
   //double ticketsell=0;                        
   int i;                              
   for(i=0; i<OrdersTotal(); i++)      
                                      
   {
       //double resultsell2=0;
       //double resultsell3=0;
       if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
       if(OrderMagicNumber()!=Magicsell && OrderSymbol() != Symbol()) continue;
      
       //if(OrderProfit()<0) resultsell2 = OrderProfit();
       //if(OrderProfit()>0) resultsell3 = OrderProfit();

       //if ( OrderType() == OP_BUY && OrderMagicNumber()==Magicbuy)  totalbuy = (totalbuy+OrderProfit());
       if (OrderType() == OP_SELL && OrderMagicNumber()==Magicsell) totalopensell = totalopensell+OrderProfit();

      
   }
   return(totalopensell);                      

}


These functions may help. When your equity is where you want it. You can call a function.

 
Iurii Tokman:
Gordon Gekko:
James:
BUDLogic v1.0:
When you post code please use the SRC button! Please edit your post.
          General rules and best pratices of the Forum. - General - MQL5 programming forum
 

Among Trailing Equity EA's, as per my experience, Equity Sentry is the best one.


  1. Account equity drops to a certain level (money/percentage/pips)
  2. Account equity reaches a certain level (money/percentage/pips)
  3. Open trades (floating loss/profit) reaches certain level

It will close all running EA's and will shutdown your MT4 terminal (best in case you are copying signals from other traders)


EA can perform several actions on Trigger:

  1. Close open trades
  2. Delete pending orders
  3. Disable Autotrading on MT4 terminal, which makes all EA‘s to stop any operations or simply prevent them from opening, modifying or closing any trades on the account. EA disables Autotrading in a very simple manner by clicking the „Autotrading“ button pro grammatically in the top MT4 toolbar.
  4. Close MT4 terminal completely.
Files:
 
Kashif Nawaz:

Among Trailing Equity EA's, as per my experience, Equity Sentry is the best one.


  1. Account equity drops to a certain level (money/percentage/pips)
  2. Account equity reaches a certain level (money/percentage/pips)
  3. Open trades (floating loss/profit) reaches certain level

It will close all running EA's and will shutdown your MT4 terminal (best in case you are copying signals from other traders)


EA can perform several actions on Trigger:

  1. Close open trades
  2. Delete pending orders
  3. Disable Autotrading on MT4 terminal, which makes all EA‘s to stop any operations or simply prevent them from opening, modifying or closing any trades on the account. EA disables Autotrading in a very simple manner by clicking the „Autotrading“ button pro grammatically in the top MT4 toolbar.
  4. Close MT4 terminal completely.
Kashif Nawaz:

Among Trailing Equity EA's, as per my experience, Equity Sentry is the best one.


  1. Account equity drops to a certain level (money/percentage/pips)
  2. Account equity reaches a certain level (money/percentage/pips)
  3. Open trades (floating loss/profit) reaches certain level

It will close all running EA's and will shutdown your MT4 terminal (best in case you are copying signals from other traders)


EA can perform several actions on Trigger:

  1. Close open trades
  2. Delete pending orders
  3. Disable Autotrading on MT4 terminal, which makes all EA‘s to stop any operations or simply prevent them from opening, modifying or closing any trades on the account. EA disables Autotrading in a very simple manner by clicking the „Autotrading“ button pro grammatically in the top MT4 toolbar.
  4. Close MT4 terminal completely.

This uses the profit loss column. NOT the equity. You can have a loss in the profit column but still have a profit over all between your equity and balance. This does not work for closing $ on equity. Look at your MT4 and see the names for the columns.

 

hello,

i am trying to design an ea. its almost 80 %  done. i need someone to complete it for me.  i have the files ready.  

i need some few adjustments.   

COME LETS DO IT TOGETHER....


BELOW IS ITS PERFORMANCE ON TEST.

EMAIL: norgbewisdom@gmai.com
Files:
Reason: