I have an automated strategy that is running on 3 accounts, that are linked with a trade copier. This morning after coming back to my desk and seeing how to system performed I noticed these messages in the Control Center logs (screenshot attached below). It seems like the Strategy is trying to cancel all orders repeatedly on the main account, and I'm trying to dig into why this might be happening.
For one, I override OnAccountItemUpdate() in my strategy code to check the realized/unrealized PnL and exit all positions and cancel pending orders if certain criteria are met. Imagine that code looks something like this
protected override void OnAccountItemUpdate(Account account, AccountItem accountItem, double value)
[B]{ double totalPNL = Account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar) + Account.Get(AccountItem.UnrealizedProfitLoss, Currency.UsDollar); if((totalPNL < -550 * IQ - 40 || totalPNL > 1700 * IQ + 40 || ToTime(DateTime.Now) > ToTime(endTime) - 60) && PositionAccount.MarketPosition != MarketPosition.Flat) { ExitLong(); ExitShort(); Account.CancelAllOrders(Bars.Instrument); trades = 1; entries = EntriesPerDirection; } } [/B]
1) Could this be the cause of these repeated logs? Is OnAccountItemUpdate called so frequently such that it would cause these log prints multiple times per millisecond?
2) Is this harmful in any way? I'd obviously want to remove the code that is causing this behavior, but want to make sure nothing is being communicated to my broker that could cause issues.
Comment