Bug in MT4

 
I am creating an EA with LIMIT ORDERS.When I program to  Delete unexecuted  limit order it is creating a looped BUY LIMIT/ SELL IMT .How to Fix it ?
 
Please show your code if you need coding help.