Maybe because the pending orders had been triggered and were no longer stop orders.
Pending orders have to be deleted, not closed, so your code should not delete a pending order.
		          No, no pending orders triggered. Return wrong value immeditely, when orders are already pending. I don't want delete pending orders.
	          
	          
          
		          Use Ctrl+f and search for OrderDelete in your code as the order is probably being deleted elsewhere.
	          
	          
          - Print your variable values used in your if statements.
- Check your return codes (OrderSend and OrderSelect) What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
I found I was doing the same thing. 
OrderSelect, OrderType(), and for some reason OrderType() was returning an incorrect value (in this case 0, OP_BUY).
With fresh eyes in the morning, whilst I was focussing on the simple 
int ordertype = OrderType();
I'd not seen I'd that I had incorrectly called OrderSelect, so it was always calling the wrong order.
Definitely worth double check of the entire route of your code, saved me an embarrassing rant :)
 
    You are missing trading opportunities:
        - Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
          Registration
          Log in
        
        You agree to website policy and terms of use
    If you do not have an account, please register
  
I placed a BUYSTOP and a SELLSTOP; but after selecting the order, OrderType() return 0 or 1 instead of 4 or 6 (no other order type placed)