Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

best practice to store persistent in OnOrderUpdate

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

    best practice to store persistent in OnOrderUpdate

    In OnOrderUpdate I need to keep the DateTime for OrderState.Filled to use later in the same method (OnOrderUpdate) when the order is being Closed / Flattened.

    (set / get)


    What is the recommended way to do this?

    Being that OnOrderUpdate is not in the main thread...and any locally defined variables are not persistent.

    #2
    typo practice

    Comment


      #3
      Hello llanqui,

      You can assign the DateTime value to a class level variable from OnOrderUpdate().

      Then you can use that variable in any method.

      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        where is the variable defined?

        in OnOrderUpdate or in the main code?

        Comment


          #5
          Hello llanqui,

          This would be a class level variable declared in the scope of the class.

          If you are not familiar with scope, see the section on 'Scope' in the 'Basic Syntax' support article linked below.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Oh, I already had this....the problem was the sequence of assignment / access of the variable, not the concept

            Comment


              #7
              Hello llanqui,

              A class level variable will continue to hold it's value until it's assigned a new value and can be used anywhere in the class.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                yes, my problem was not that, it was a logic sequence error...works now, thanks

                Comment

                Latest Posts

                Collapse

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