Forums › ProRealTime English forum › ProOrder support › trailing stops to all positions after they hit a combined profit? › Reply To: trailing stops to all positions after they hit a combined profit?
Hey @Nicolas – I’ve been testing the above and recently found a flaw in my code;
1 2 3 4 5 6 7 8 9 10 11 |
// test the current floating profit and close orders if needed FloatingProfit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gains if FloatingProfit > 50 and floatingprofit <150 then SET STOP PTRAILING 4 endif if FloatingProfit > 151 and floatingprofit <250 then SET STOP PTRAILING 2 endif if FloatingProfit > 251 then SET STOP PTRAILING 1 endif |
One of these functions is calculating the total gain value for the system rather than only the current open positions;
(close-positionprice)*pointvalue)*countofposition)/pipsize
The solution or advice I’m looking for is to find a way to reset the floatingprofit at each new position open. Is there a function to do this?
Would this work … subtracting the system profit using strategyprofit function from the total accumalative floatingprofit:
FloatingProfit = Strategyprofit – (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual open trade gains
Thanks in advance.
Bart