@josecortesllobat .. I do not really know how to put your code into constants and variables.. Never worked with those stuff and same goes to coding. After lots of back reading I have come up with something but it is not working, and I am afraid I think I am going down the wrong road here
.. Please take a look and teach me how to implement what you wrote previously.. greatly appreciated
https://fxdreema.com/shared/163e9qHvb

Hi @AlphaOmega
Regarding to your question: TP average. Probably there is a much efficient way to code it because fxDreema allows to reach the same goal with multiple ways. I assume that each child trade has a fixed TP that probably will be the same as for the parent trade. Let´s call it 'TakeProfitPips'. Using your example,
nTrades == 0 (reset it as per your need)
TakeProfitPips == 100
OpenPrice_ParentTrade == 1.00000
nTrades == 1
TPLevel_ParentTrade == OpenPrice_ParentTrade + TakeProfitPips (as price fraction) = 1.00000 + 0.00100 = 1.00100
OpenPrice_ChildTrade1 == 1.00010
nTrades == 2
TPLevel_ChildTrade1 == OpenPrice_ChildTrade1 + TakeProfitPips (as price fraction) = 1.00010 + 0.00100 = 1.00110
TakeProfitAv == (TakeProfitPips + (TPLevel_ChildTrade1 - OpenPrice_ParentTrade) "as pips")) / nTrades
= (100 + (1.00110 - 1.00000) "as pips" ) / 2
= (100 + 110) / 2 = 210 / 2 = 105
Modify ChildTrade1 TP to 105 pips -> TP_ChildTrade == 105
OpenPrice_ChildTrade2 == 1.00020
nTrades == 3
TPLevel_ChildTrade3 == OpenPrice_ChildTrade3 + TakeProfitPips (as price fraction) = 1.00020 + 0.00100 = 1.00120
TakeProfitAv == (TakeProfitPips + [(TP_ChildTrade ) + (TPLevel_ChildTrade2 - OpenPrice_ParentTrade) "as pips"]) / nTrades
= (100 + [(105) + (1.000120 - 1.00000) "as pips" ] )/ 3
= (100 + [(105) + (120)] )/ 3 = 325 / 3 = 108.3
Modify ChildTrade2 TP to 108 pips -> TP_ChildTrade == 108
.... and so on