Hi @biztet
@roar built that amazing profit checker code. I can say that works greatfully and it was built using variables.

"the ea will record the highest total current profit achieved. As the picture show its 2200."
'maxprofit' == 0 (reset it as per you need)
If 'Equity' > 'maxprofit' -> 'maxprofit' == "Equity'
"When the number decrease more than certain % from the highest current profit, e.g 60%, the ea will close all trade, and we secure the 40% profit0."
If 'Equity' <= 'maxprofit' -> calculate 'Ratio' as 'Equity' / 'maxprofit'
If 'Ratio' < MinRatio (0.6 for you) -> Close positions
"Also to set the minimum current profit, lets say 1000. The rule applies when the current profit reach minimum 1000."
You just need to add condition blocks somewhere within your code to activate the 'profit checker'. This might be an approach:
Define -> bool ProfitCheckerON false (reset it as per your need)
Condition block -> If 'Equity' > 1000 -> ProfitCheckerON == true
Condition block -> If ProfitCheckerON == true -> true output is activated and the profit checker starts to work
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
Not sure if that is what you are looking for strictily but might be a starting point.