Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to find out the outstanding trade upon recovery from a power or network loss?

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

    How to find out the outstanding trade upon recovery from a power or network loss?

    Hello,

    I am developing a strategy and would like to handle the recovery upon a power or network loss. I would like to find out if the current position is Long/Short, and what the opening price of the current position was. Where should I handle this recovery (which call back function) process? Is this even possible, or when a power or network loss, the strategy logic can no longer control the outstanding trade? Thanks

    Billy

    #2
    Hello billythekid72,

    Yes that is possible, that is how the strategies start behavior works to sync orders and positions. This is heavily dependent on how the strategy is coded, it essentially needs to work identically historically and in realtime. If the strategy is stopped mid trade and then re enabled it needs to be able to recalculate submitting the order during its historical processing so that order can be transitioned into a realtime order and matched. The same would happen for positions, the strategy needs to enter historically into the same position and then when it enters realtime it can resume it. You can read about syncing in the following page:



    Comment


      #3
      Hello,

      In the following case (Wait until flat, synchronize account​) if an outstanding Account position was submitted with SetStopLoss and SetProfitTarget, will NinjaTrader honor the stop-loss and profit target and wait for the Account position to flatten per stop-loss and profit target settings?

      Wait until flat, synchronize account
      This combination should be used when you want to begin trading your strategy off a flat state with minimal user interaction to sync your Account Position prior to start.



      When your strategy starts it will check for any active orders previously generated by the strategy on your account and cancel those first. Should the strategy be unable to cancel and receive confirmation on the cancellation of these orders within 40 seconds the strategy will not start and an alert will be issued. After the strategy is successful in cancelling any orders that required action it will check your current Account Position and compare it to a flat state. On multi-instrument strategies it will perform this check for all instruments used by the strategy.



      •If the Account Position is flat already, no reconciliatory order will be submitted. The strategy will then wait for the Strategy Position to reach a flat state as well before submitting any orders live.

      •If the Account Position is not flat, NinjaTrader will submit a market order(s) to reconcile the Account Position to a flat state. The strategy will then wait for the Strategy Position to reach a flat state before submitting live orders.
      Note: The reconciliatory market order is submitted outside of the strategy so your strategy will not be able to manage it from methods like OnOrderUpdate(), OnExecution(), etc.

      Comment


        #4
        Hello billythekid72,

        No that is for starting in a flat state. The strategy waits until it becomes flat to enter realtime. if the account is not flat it will make the account flat by submitting orders to do that.

        Comment


          #5
          Hello Jesse,

          I am somewhat confused. The behavior I seek is this: I want NT to cancel any outstanding Strategy position (if they do not match up with the Account position) and keep the active Account position to completion with NinjaTrader honoring the SetStopLoss and SetProfitTarget. How can I achieve this?

          Comment


            #6
            Hello billythekid72,

            There is not a behavior like that, there is no outstanding strategy position after you disable the strategy that's just an account position at that point. The strategy needs to re create that position as it processes the now historical data to be able to resume it.

            When it originally created that position and orders that was a realtime bar, now that the strategy has been disabled and re enabled that's now a historical bar where the position and orders were created. It needs to re submit that order to enter a position on that same bar so the platform recognizes that the existing account position is that strategy position and syncs them. Keeping orders active is the same process, the strategy needs to re submit those orders after entering the historical position so that the historical strategy orders are transitioned into realtime and synced. Orders that don't match will be cancelled so if the strategy doesn't re create the orders they will be cancelled on the account.





            Comment


              #7
              Hello Jesse,

              If I use Wait until flat strategy behavior, I could disable the strategy once returned from a power loss or network down, and wait for any outstanding Account position to continue (presumably they will be managed by NT honoring SetStopLoss and SetProfitTarget settings) to completion. Thereafter I could start the strategy again, at that point all will be flat and sync. That would work, wouldn't it?

              Wait until flat
              These are the default settings for your strategies and are the least disruptive in terms of handling your current Account Position. It assumes your Account Position is in a flat state.



              When your strategy starts it will check for any active orders previously generated by the strategy on your account and cancel those first. Should the strategy be unable to cancel and receive confirmation on the cancellation of these orders within 40 seconds the strategy will not start and an alert will be issued.



              •If the Strategy Position is flat, then the Account Position and Strategy Position are assumed to be in sync with each other. The next order placed by your strategy would be placed as a live order to your account.

              •If the Strategy Position is not flat, the strategy will place all trades in a "virtual" sense until the Strategy Position reaches or crosses a flat state. Once a flat state is achieved the Strategy Position will be assumed to be in sync with the Account Position and all future orders will be placed live.
              Critical: Should your Account Position not be flat at the point in time the Strategy Position reaches a flat state your Account Position and Strategy Position will NOT be in sync.

              Comment


                #8
                Hello billythekid72,

                Yes that would be the default behavior for a strategy to wait until flat before starting. The strategy shows up as yellow in the control center until it has started working in realtime.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                81 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                149 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                79 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                52 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                59 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X