Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Repeated "Cancel all orders account=XXXXXX" messages in log

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Repeated "Cancel all orders account=XXXXXX" messages in log

    Hi NT8 fam,

    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)

    Code:
    [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]
    These are really just emergency failsafe conditions that should execute if the profit target logic in other parts of the strategy failed to execute properly. My questions are:

    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.
    Attached Files
    Last edited by jaybedreamin; 03-23-2023, 10:01 AM.
    jaybedreamin
    NinjaTrader Ecosystem Vendor - Zion Trading Algos

    #2
    Hello jaybedreamin,

    Are you using prints to debug the script and understand the behavior?
    https://ninjatrader.com/support/foru...121#post791121

    Are you asking why the condition is evaluating as true multiple times?

    Could this be the cause of these repeated logs?
    Possibly, it could be anything running in NinjaTrader.
    Its necessary to debug to confirm where an issue is coming from, and why it is occurring.
    For example, if you comment the code out does the behavior stop? If you uncomment that code does the behavior return? (This would confirm that this the code cause the behavior)
    To know why, print the time and all values in the conditions or used for calculations to the output window.

    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.
    Harmful in that this would cancel an order that is protecting an open position?
    Harmful in that this would close a position you did not intend to close?
    Harmful in that trying to manage a position through an account will not reflect in the strategy?

    It would be hard to say. This would be specific to the position you want the strategy to have and the account to have, and what orders you want to be working.

    Regarding spamming a broker server with invalid requests, this drives up traffic and is not a good idea.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    20 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    120 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    63 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    45 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X