PTScalper wrote:Because cTrader natively supports C# and LINQ , you can bypass the clunky loops required in MQL. The History and Positions collections natively include .NetProfit (which automatically bundles swap and commission), making the intraday PnL calculation extremely clean.
The LINQ version is much easier to read than the MQL loops, and reconstructing start-of-day equity from closed profit is a neat way to avoid storing state.
The part I'd rethink is house money scaling with '% of Daily Profit to Risk' defaulting to 100. Once the day is up 2%, the next trade can risk the entire day's profit, so a single stop-out takes you back to flat. The opening post goes the other way: after a large green morning, the idea is to protect it. At 25 to 50% of the day's profit, a good morning still allows a slightly bigger ticket without making it all-or-nothing.
Two edge cases in the maths. Balance minus today's closed profit gives the wrong starting figure on a day with a deposit or withdrawal, because the balance moved for reasons unrelated to trading. And Server.Time.Date with the robot set to UTC starts the day at UTC midnight. For most brokers the trading day, and the swap charge, turns over at 17:00 New York, so trades closed in the late US session land in the wrong day.
Returning a risk of zero at the hard stop is good, but nothing stops a manual order. I'd have the bot also close positions and print a clear message when the 3% is hit.