I’m trying to use the cumulative profit of an strategy for calculating the position size. However, I’ve noticed that the Performance.AllTrades.TradesPerformance.Currency.C umProfit variable is lagging behind (with two trades) the closed trades in a backtest (see screenshot, I couldn't upload the Excel file). That’s weird in my opinion, because the CumProfit should be updated after each trade, and thus should not be lagging behind, if I understand CumProfit correctly?
I searched this forum, and found various topics on CumProfit, including an sample, yet all of them used Performance.AllTrades.TradesPerformance.Currency.C umProfit, which in my case gives wrong values, which suggest that I’m doing something terribly wrong.
So, how can I use CumProfit in a way that is usable and true to the real strategy results during backtesting? I tried checking with Print() for open positions at the time of closing an trade (there were), and thus tried Position.GetProfitLoss(Close[0], PerformanceUnit.Currency), which still lags (though now one trade), and also gives wrong values.
I’ve tried changing my simple crossover strategy (see attachment), so that there weren’t any short trades entered on the same bar an long was exited; this didn’t help. I also included the condition “if (Performance.AllTrades.Count > 1)” to remove the lagging; this worked, however, for the last trades this doesn’t give any values, so that is also not an solution.
How can I use the correct cumulative profit in an backtest strategy? Any ideas are highly appreciated,
Regards,
Comment