Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to programatically close all orders in position

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

    #16
    When you shutdown NT and start up again there is no "finding" old orders. NT6.5 begins the strategy completely over again from scratch with no knowledge of any prior orders. There is no way to map orders back.

    In NT7 if you have sync account position set to true it will automatically try and map back existing orders on your account to your strategy. Only exact matches will be mapped back. Orders that cannot be mapped back will be canceled.
    Josh P.NinjaTrader Customer Service

    Comment


      #17
      Thanks, good to know about that feature. What is the exact syntax in the code to sync account in Initialize method?
      So basically, it is safe to assume that in NT7 there will be no orphaned orders related to specific strategy once NinjaTrader starts? And I can check each of the previously saved iOrder objects to verify that they are not NULL? If NULL - that would mean that this order no longer active... Is it correct statement?

      Comment


        #18
        You can enabled the autoSync on startup of the strategy via SyncAccountPosition = true; in the strategy Initialize().

        If you restart the strategy, it would recalculate and try to remap - however there's no guarantee it can do so, therefore you would need to add checks and potentially account for this in your code if needed. You will need to nullify your IOrder objects as needed, for example reset the targetOrder one to null once the target reached filled / cancelled state etc.

        Comment

        Latest Posts

        Collapse

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