Help modifying Highest profit orders only...thanks!

 

Hi. My EA places approx 10 buy and 10 sell orders at different intervals. Many times they exist together as open orders.

I'm looking for code to modify the stop loss for only the order that is the LARGEST in profit in relation to how many orders are open.

Example: I have 10 open buy orders and 8 are negative, and 2 are positive (in profit). I also have 9 sell orders opened at the same time.

So, 10 open buys - 9 open sells = 1 open buy. So results are to modify the 1 "extra" buy order only and it must be the buy order with with the largest open profit.

All orders are using identical OrderMagicNumber.

Is this possible?

Thank you

Reason: