It appears that the code below only checks the strategy p&l once the current trade is stopped-out?
Is that right?
Very often, the marked-to-market p&l is less than the “stopout” level but the algo carries on trading until the current position is exited. It seems to be only then that it checks the strategy p&l. I would like it to check the p&l after every change in price and stop trading immediately the “stopout” level is hit. How is this written?
Many thanks
if StrategyProfit <= StopOut then
QUIT
endif
That’s right, STRATEGYPROFIT is updated with closed trades.
You can use POSITIONPERF to know actual positions PnL.
So,
strategyprofit + p&l from open positions = realtime p&l
It seems POSITIONPERF is a ratio.
What is the simplest way to convert this into a currency amount for an open position … positionperf*positionprice?
Thanks
You can compute the floating profit with this function:
//floating profit
floatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gains
and add it to STRATEGYPROFIT to get the whole account profit (closed trades + not closed ones).
Great – thank you Nicolas