Calling a script from an EA triggered by entering a Pending order

 

my aim is to find or write an algorithm that triggers a call to a script that closes all profitable trades. I want it to be triggered by entering a pending order.  the call to trigger will be in an EA.  I have searched all over the internet and the MQL and cannot find specifically for this requirement, can anyone help or point me in  the right direction?  Thanks, Really Appreciated