Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Are there Interrupt Priorities of IOrder methods

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

    Are there Interrupt Priorities of IOrder methods

    Is there a priority of IOrder method execution?
    Do these methods interrupt other methods until complete?
    Is updated information available immediately within a method.

    The methods of interest are:
    OnBarUpdate
    OnOrder
    OnExecution
    OnPosition

    For example while processing in the OnBarUpdate method, can OnExecution interrupt its flow until done. And thus variables affected by OnExecution could change midstream during the processing of OnBarUpdate.

    Can OnExecution interrupt OnOrder?

    #2
    Camdo, I would suggest you review this link closely, for example there's internal strategy logic that would be called after OnOrderUpdate, but before the OnExecution. In general you would see OnOrderUpdate called first > OnExecution > OnPositionUpdate



    The OnBarUpdate is just driven by the by eac tick coming in or the last tick closing the bar / opening a new one (CalculateOnBarClose setting).

    The NinjaTrader core is multithreaded and as such race conditions can occur.

    Comment


      #3
      Basically you should ask if mentioned methods are running of the same thread.

      From my experience I would say they do, otherwise you would need to protect access to your global objects via a mutex.
      I would expect that NT rather runs all above mentioned functions off the same thread so that the NinjaScript user does not have to think about thread syncronisation.

      Better wait for confirmation of NinjaTrader Bertrand, Dirk, or Josh...

      regards

      andreas

      www.zweisteintrading.eu

      Comment


        #4
        Thank you andreas and Bertrand
        I will re-phrase the question:

        Does OnExecution, OnOrderUpdate, OnPositionUpdate, and OnBarUpdate run on the same thread?

        Comment


          #5
          Development will get back to you at a later point in time. Thank you for your patience.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Development has informed us that all NinjaScript events / methods of a particular strategy / indicator instance are executed in the same thread. For backtesting / optimization in the Strategy Analyzer however different strategies could be running on different threads - therefore you should not code your scripts to be reliant on a single thread execution.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            608 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            355 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            560 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            561 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X