How do I check all my orders and find spacific ones and then change the TP?

 

Hi,


Im writing an EA and I am having some trouble writing a loop to do something


I want to make able to look through all my open orders and see what order has the largest target profit and and then do two things


1) I want it to tell me how many lots all the orders that have that target profit are combined.


ie:


order 1

lots 2

TP 5


order 2

lots 1

TP 4


order 3

lots 1

TP 5


would tell me that the highest TP is 5 and the total lots trying to be sold at that TP is (2+1=3)


1) Once it figures out what the TP is it will go through the orders again and then change the TP of all of thoes orders by a constant.


ie:


Before


order 1

lots 2

TP 5


order 2

lots 1

TP 4


order 3

lots 1

TP 5


TP 5, lots 3


After


order 1

lots 2

TP 5-A


order 2

lots 1

TP 4


order 3

lots 1

TP 5-A


TP 5-A, lots 3



Can anyone give me some helpful hints on how I can make a loop that will figure out what I want it to figure out and change the orders that I want it to change.


Thanks for helping me

Bondy3

Reason: