How to automatically re-calculate the total profit from total order

Chia Tung Lee  

Hello all,

I'm writing a EA similar to Martingale. But I encounter a problem while I want to re-calculate the "take profit" for all of my current orders.

Here are the processes,

1. I set up the target total profit would be 10 USD at beginning before any order is placed. 

2. Now, the 3rd order is going to place.

3. EA is calculating the take profit point, within all 2 placed orders and 3rd order, to reach 10 USD profit.

4. After calculating, EA is going to modify take profit point for 2 placed orders and set up the 3rd order.

5. 3rd order is placed with new take profit point and also other two orders has been modified.

6. Then while reach the new take profit point, 10 USD profit get.

Is anyone could give me a example or advice to write this processes? 

Now, I could only finish 1st step, but I am not sure how to set up a unknow take profit point.

Please help help, many thanks. 

Chia Tung Lee  

Is anyone could help? Even a hint or something relative whit this topic?