EA closes all positions instead of one

Hello everyone, I have a small problem with my EA, I would like him to close the winning position only on GBPUSD. but now he closes the winning position on all the instruments. can you help me please. here is the code:

//+------------------------------------------------------------------+
//|                    TakeProfit 1 |
//+------------------------------------------------------------------+

#property copyright ""
#property link      ""


                                       
extern double My_Money_Equity_Target=3;  
                                         
int Slippage=4;                                        
int i;

double   EquityTarget;
//+------------------------------------------------------------------+
                                  
//+------------------------------------------------------------------+
int init()
  {
//---- 
   EquityTarget = AccountEquity()+My_Money_Equity_Target;
//----
   return(0);
  }
//+------------------------------------------------------------------+
                               
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
                                         
//+------------------------------------------------------------------+


int start()
{
if (AccountEquity()>= EquityTarget)

   {
    for(i=OrdersTotal()-1;i>=0;i--)
       {
         if(OrderSelect(i,SELECT_BY_POS))
         {
            bool Res=false;
            if(OrderType()==OP_BUY)
            {
               Res = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,clrNONE);
            }else if(OrderType()==OP_SELL)
            {
               Res = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,clrNONE);
            }else
            {
               Res = OrderDelete(OrderTicket());
            }
         } 
       }
      Print ("Equity reached to ",DoubleToStr(AccountEquity(),2));
      if(!Res)    return(0);
      EquityTarget = AccountEquity()+My_Money_Equity_Target;
   }  
   
   Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit(),
           "\nMy Account Equity Target: ",EquityTarget);
   
  return(0);
}

use this:

if ( OrderSymbol() == GBPUSD) {

// thene delete

}

// or use this for close wining posotions.

if ( OrderSymbol() == GBPUSD &&  OrderProfit() > 0) {

// thene delete

}

there’s no if condition to check the symbol of the open position.
also there’s no filter to choose positions in profit.

Great, thank you very much :slight_smile:

!!!

search for it …

OrderSymbol() to get opened position symbol name and OrderProfit() to finde profitable orders…

!!!
I was referring to his code.