Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnExecutionUpdate executes multiple times

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

    OnExecutionUpdate executes multiple times

    Hello,

    with using the Strategy Analyzer I run a strategy using a trailing stop with SubmitOrderUnmanaged.

    When the order gets filled, NinjaTrader runs OnExecutionUpdate one time and then another time although it is the same order.

    What is the reason why the OnExecutionDate gets executed two times?

    Sincerely
    Gerik

    #2
    Hello Gerik,

    Thank you for your post.

    In order to better understand the behavior of the backtest in Strategy Analyzer, I recommend adding Print() statements to your script. You could add a print inside of OnExecutionUpdate() that will show up in the NinjaScript Output window and offer additional information regarding why the method is being called more than you are expecting. Since an execution object is used to represent the execution, you could even add a print such as the following:

    Print(execution.ToString());

    For more information regarding OnExecutionUpdate():


    For a more detailed resource regarding using prints to debug your scripts:


    Please let us know if we may be of further assistance.

    Comment


      #3
      Hi Emily,

      thanks for answering. I used the print command in OnExecutionUpdate. I receive a strange message:

      execution='NT-00003-9485' instrument='MES 12-22' account='Backtest' exchange=Default price=3680 quantity=1 marketPosition=Long orderId='NT-00004-9485' time='2022-10-03 19:30:00' sod=False statementDate='0001-01-01'

      The orderID NT-00003-9485 is a stop order that has cancelled before.

      Any idea why the stop order orderID gets filled although it has been cancelled?

      Sincerely
      Gerik

      Comment


        #4
        Hello Gerik,

        Thank you for your reply.

        In your example, NT-00003-9485​ is an Execution ID and NT-00004-9485​ is an Order ID. These are two different values; if you had a stop order that was cancelled, it is possible that the orderID for that order matches the executionID from your example, but that would just be coincidental and not related to the cancelled order now getting filled. I believe that the executionID is typically generated at the exchange when trading a live account, which means the results may vary when trading in simulation or doing a backtest vs. trading on a live account.

        The different parameters for OnExecutionUpdate() are listed on the help guide page here:


        Please let us know if we may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        66 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        141 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        76 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        47 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        51 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X