How to close orders in a certain order?

 

Hi,

Can you help solve this issue:

Suppose that exist a signal to close ALL open market orders in terminal.

EA must close all orders in following order:

first close order with biggest LOSS, last order with biggest PROFIT?

Thank you.

 
Loop through all your open orders and find the one with the biggest loss using OrderProfit(), same for the next, etc, etc . . . or if you have lots of orders and want to get creative use an arry to hold the profit/loss figures and ticket numbers and sort the array from biggest loss (-ve profit) to biggest profit then run through the array in order and close the orders.
 
Thank you. In fact I know what to do. I can not program it! So if you want to help...
 
Grigor:
So if you want to help...
I just did . . . I'm not about to write your code for you though, if you need that go here: Write my code for me ! !
 
Grigor:
I can not program it! So if you want to help...
No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
Reason: