Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reattaching to Orders After a Crash

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

    Reattaching to Orders After a Crash

    I use managed orders in my strategy with SetProfitTarget(). Let's say my strategy has taken 1 position. I can easily record this to disk using a C# file I/O operation. Then say my computer freezes and I have to restart it. Then I restart NinjaTrader and the strategy. I know from what was recorded on disk that a position was taken. Can I re-attach the IOrder variable I was using in the strategy to the outstanding trade? This would give me a way to pickup where I left off before the crash.

    #2
    Hello,
    Thank for posting today

    I have seen your inquiry and am looking in to currently. Thank you for your patience.
    Alex G.NinjaTrader Customer Service

    Comment


      #3
      Hello,
      Thanks for your patience.

      You will not be able to reattach the IOrder object to order since the IOrder.OrderId and IOrder.Token properties do not stay constant and can change throughout the life of the order objects.

      Please let us know if we may be of further assistance for anything NinjaTrader.
      Alex G.NinjaTrader Customer Service

      Comment


        #4
        Then say after the crash, I open the same chart I had before and run a different strategy that does nothing but call SetProfitTarget(), the intention being to set the profit target of the trade that is on before the crash - will that work?

        Comment


          #5
          Hello reynoldsn,
          Thanks for the reply.

          The SetProfitTarget() method in this moment wouldn't attach to an order unless that order is placed through the strategy.

          NinjaScript does not have a way of reattaching to this order so a profit target or stop loss could not be placed.

          You could however place them manually a profit target as an OCO order, which what NinjaTrader does for ATM's, that would protect your current position. However, you would not be able to do this through NinjaScript.

          Please let us know if we may be of further assistance for anything NinjaTrader.
          Alex G.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by reynoldsn View Post
            Then say after the crash, I open the same chart I had before and run a different strategy that does nothing but call SetProfitTarget(), the intention being to set the profit target of the trade that is on before the crash - will that work?
            That depends on the settings that you are using. you can setup NinjaTrader to recalculate the position based on history, and reissue the necessary orders, based on such.

            Comment


              #7
              The SetProfitTarget() method in this moment wouldn't attach to an order unless that order is placed through the strategy.
              To review, the strategy places an order and uses SetProfitTarget(). Before target is reached, the strategy is suddenly closed. Will the target still be in place?

              Comment


                #8
                Hello,
                Thanks for the reply.

                This depends on who your connected to and where orders reside. http://ninjatrader.com/support/forum...ead.php?t=5349

                Once the order fills and places the profit target and the profit target is accepted, working and this order resides at the brokerage then yes the strategy closing or crashing will not affect that order.

                However, this is all based on the order residing at the brokerage and being in a working state before the strategy is closed suddenly. If you have an order that has a profit target set for it but this order has not filled, this profit target will not be submitted if the strategy is not actively working.

                Also if this does occur we highly recommend that you contact the orders desk to manage this strategy manually and not rely on the strategy submitting the order successful before a crash.

                Please let us know if we may be of further assistance for anything NinjaTrader.
                Alex G.NinjaTrader Customer Service

                Comment


                  #9
                  I am currently using AMP.

                  If I may quote:
                  However, this is all based on the order residing at the brokerage and being in a working state before the strategy is closed suddenly. If you have an order that has a profit target set for it but this order has not filled, this profit target will not be submitted if the strategy is not actively working.
                  After an order is placed and a target set, is there a way to get an indication in the strategy that the target order was completed?

                  Just to clarify the big picture: I want monitoring and alerts in place. I want some way to know if the target order on my long/short entry was placed successfully and is still there even if my strategy crashes. If so, then I need to be able to query that information and verify it when I reconnect the strategy.
                  Last edited by reynoldsn; 07-09-2015, 07:23 PM.

                  Comment


                    #10
                    Hello,
                    Thanks for the reply.

                    After an order is placed and a target set, is there a way to get an indication in the strategy that the target order was completed?
                    Yes, you can track the order by setting it to an IOrder object within the OnExecution() method and then determining it's state by using the OrderState values.

                    Here is a link to the IOrder documentation from the help guide. http://ninjatrader.com/support/helpG...nt7/iorder.htm

                    Here is a link to the OnExecution() method documentation from the help guide.http://ninjatrader.com/support/helpG...nexecution.htm

                    ...and is still there even if my strategy crashes.
                    This would impossible to tell until the order updates and you receive an update from the brokerage. Again the IOrder number would not match so this order could be a different order depending on how many positions you have set before hand.

                    Also, if your strategy crashes and you are in a position it is highly recommended you contact the orders desk to handle this order manually.

                    Note, you will not be able to verify with a 100% accuracy the order that updates is the same you placed before the crash.

                    Please let us know if we may be of further assistance for anything NinjaTrader.
                    Alex G.NinjaTrader Customer Service

                    Comment


                      #11
                      What would you recommend in terms of the best way to get notification upon a strategy or NinjaTrader crash?

                      Comment


                        #12
                        Hello,
                        Thanks for the reply.

                        If NinjaTrader crashes, since it is a Windows based platform, it should produce an error message from windows.

                        As far as the strategy suddenly stopping you should be able to put a notification on the onTermination method of the strategy. When the strategy shuts down it will perform the onTermination method. Here is a link to the help guide documentation for the

                        Also we do not recommend that you let a strategy run without actively monitoring it as any number of unpredictable events can occur (such as power lose) that can not be managed by code within a strategy.

                        Please let us know if we may be of further assistance for anything NinjaTrader.
                        Alex G.NinjaTrader Customer Service

                        Comment


                          #13
                          Say the strategy takes a trade and then crashes before closing the trade. When I restart the strategy (and assuming the trade hasn't exited yet), is there any way for the strategy to query and determine the fact that a position is still open?

                          Comment


                            #14
                            Hello reynoldsn,
                            Thanks for posting today.

                            You can check and attempt to sync the account position to your strategy position.

                            Here is a link to our help guide that describes syncing account positions. http://ninjatrader.com/support/helpG..._positions.htm

                            Here is a link to the our help guide that describes strategy position vs account position. http://ninjatrader.com/support/helpG..._account_p.htm

                            Please let us know if we may be of further assistance for anything NinjaTrader.
                            Alex G.NinjaTrader Customer Service

                            Comment


                              #15
                              Can all of the 'sync' options be tested with Market Replay?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              563 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              329 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
                              547 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