Houston, I have a problem!

 

This coding was to eliminate only pending buy and sell stop orders. It unfortunately is deleting both the pending buy and sell stop orders, but also the orders that are active and in play. How can I change this to only eliminate the pending and not the active buy and sell stops that are in play? Your ideas will be greatly appreciated.

Dave 77, TGIF

Houston, TX

For cnt=1 to TotalTrades

{

mode=OrderValue(cnt,VAL_TYPE);

If mode>OP_SELL then

{

If (Minute>58)then // Delete pending Sell Stops.

{

DeleteOrder(OrderValue(cnt,VAL_TICKET),Cyan);

Exit;

};

};

If mode>OP_BUY then

{

If (Minute>58)then // Delete pending Buy Stops.

{

DeleteOrder(OrderValue(cnt,VAL_TICKET),Cyan);

Exit;

};

};

Reason: