Need help with a simple code !

[Deleted]  
I just can't figure this one out. I need to open to orders, buystop and sellstop simultanously. And when one triggers to market close the other.
[Deleted]  

RB

Enter the Pending orders for your breakout strategy.

Keep counting the BuyStops & the SellStops

When a count of BuyStops comes up as zero, close the pending SellStop.

Use the functions below as a basis

Good Luck

-BB-

int CountOrdersByTypeAndMagicNumber(int iType, int MN)
{
int icnt, itotal, retval;

retval=0;
itotal=OrdersTotal();

   for(icnt=0;icnt<itotal;icnt++)
     {
      OrderSelect(icnt, SELECT_BY_POS, MODE_TRADES);
       // check for position, symbol & MagicNumber
      if((OrderType() == iType) && (OrderSymbol() == Symbol()) && (OrderMagicNumber() == MN)) retval++;
        
     }

return(retval);
}


void ClosePendingBuyOrders(int MN)
  {
  int i, iTotalOrders;
   
   iTotalOrders=OrdersTotal()-1; // Rosh line
  
   for (i=iTotalOrders; i>=0; i--) // Rosh line     
   
   { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
      { 
         if (OrderMagicNumber()==MN)
         { 
            if (OrderType()==OP_BUYSTOP) OrderDelete(OrderTicket());
            if (OrderType()==OP_BUYLIMIT) OrderDelete(OrderTicket());
            
         }
      }
   }
}

  void ClosePendingSellOrders(int MN)
  {
  int i, iTotalOrders;
   
   iTotalOrders=OrdersTotal()-1; // Rosh line
  
   for (i=iTotalOrders; i>=0; i--) // Rosh line  
   { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
      { 
         if (OrderMagicNumber()==MN)
         { 
            if (OrderType()==OP_SELLSTOP) OrderDelete(OrderTicket());
            if (OrderType()==OP_SELLLIMIT) OrderDelete(OrderTicket());
         }
      }
   }
}