You may take some example of coding fom this thread
EA to close all open order of GBPJPY
(it is EA to close the orders on specify pairs only).
And it is the same (to close on specific pair) for pending orders
this EA delete all pendind orders
(EA as well).