hedging negative order

 
when iv opened to many orders ,one of theme has a drawdown and i want to hedge it,,,,how to prevent repeating the opposite order more than  once??thanks
for(int cnt=0;cnt<OrdersTotal();cnt++)
     {
     
      result=OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()==OP_SELL &&OrderSymbol()==Symbol() &&OrderMagicNumber()==MagicNumber&&Bid-OrderOpenPrice()>=30*MyPoint )  
        {
        
       result=OrderSend(Symbol(),OP_BUY,lots,Ask,Slippage,0,0,"",MagicNumber,0,Blue);   
          
        }
     }
 
  1. Why did you post in the Root / MT5 General section instead of the MQL4 section (bottom of the Root page?)
  2. Before opening the buy order, see if you already have one open. If you open multiple orders, you'll need to remember the original ticket and the hedged one in an array.
  3. Personally I wouldn't do it. Let the SL close the loosing order.
 

1-Sorry for this mistake

2-Using tickets is a great idea but i must find a way to make a connection between the 2 tickets thanks

3- It is just an idea it may be succeed 

 
hadher ramadhan: 2-Using tickets is a great idea but i must find a way to make a connection between the 2 tickets thanks
You have the connection, when you find the loosing order not in the array, and open the hedge
 
whroeder1:
You have the connection, when you find the loosing order not in the array, and open the hedge

thank you i found it