Hi Maksym,
right now, I’m trying to implement the trailing take-profit feature for the Combo bot. During extensive testing, I noticed a completely different, more general issue related to closed deals. I’ve seen it with Combo, but I think this is very likely also with DCA bot.
Issue:
When a deal was closed, the in-memory deal stats in DealMonitor were removed before being flushed to the database. As a result, values like runUpPercent and drawdownPercent could stay at 0 or lose their latest updates in closed deals.This can be seen good when trading with high leverage and high volatility.
Fix:
Instead of deleting the cached stats immediately on deal close, we now flush the pending stats to the database first and only then remove them from memory.
Result:
Closed deals now keep the correct final runUpPercent, drawdownPercent, and other tracked deal stats.
Please notice my attached patch, so you can see what fixed this for me.
I’ve tried to make as few changes as possible.
bf938e.patch.txt (4.3 KB)
Hope this helps.

