if (Sellstop becomes sell) ....

 
if((iMA(NULL,0,89,0,MODE_EMA,PRICE_OPEN,0)>Bid))
     {
         result1=OrderSend( Symbol(),OP_BUY,Lots,Ask,Slippage,                    //--------------Order 1
                           SL1,
                           TP1,
                           Comment,MagicNumber,0,Red);
                OrderSelect(result1,SELECT_BY_TICKET);
                order1= OrderOpenPrice();                                         //Order 1 price 
                order2= order1 - expips*MyPoint;                                  //Order 2 price
                Alert("Entry 1: ",order1,". Entry 2: ",order2);         
         result2=OrderSend( Symbol(),OP_SELLSTOP,Lots,order2,Slippage,          //--------------Order 2
                           SL2,
                           TP2,
                           Comment,MagicNumber,0,Red);

         if(TotalOrdersCount()== 2 && totalpending() = 0)                       //Sellstop comes Sell
         {
            result3=OrderSend( Symbol(),OP_BUYLIMIT,Lots,order3,Slippage,        //--------------Order 3
                           SL3,
                           TP3,
                           Comment,MagicNumber,0,Blue);
            Alert("----------------Total: ",TotalOrdersCount(),". Pending: ",totalpending());
            
         }
     }
 
I think if (TotalOrdersCount () == totalpending ()) { consider the current time But in fact, I need Buystop to run and become Buy So when considering If, the clause is false
 
Your highlighted condition is always false because you just opened a Sell Stop directly above.
 
William Roeder:
Your highlighted condition is always false because you just opened a Sell Stop directly above.

I want the "if" segment to do when buystop becomes buy, what code I need