Calculate profit of an order

 
Is it possible to determine how much profit a certain order has made? I am aware that an order can technically not generate a profit, but the resulting deals can. Hence, I somehow have to determine which deals were a result of a given order and than add up all the profits of the individual deals to calculate the entire profit for a given order. The problem with this approach is that assuming you are using SL and TP and you place 10 buy orders and your TP is triggered, selling the volume of the 10 orders (lets say 0.1 lots). A deal will be made that sells the entire 0.1 lots, but how does one determine which of those 10 buy orders contributed towards the final profit and how much they contributed?
Reason: