Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Which StartBehavior to Exit Open Strategy Position?

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

    Which StartBehavior to Exit Open Strategy Position?

    Hi,

    My strategy often holds positions over the weekend. And the problem is that my data connection (CQG/NinjaTrade Continuum) is usually disconnect from your end over the weekend. (I understand this happens so you can run server maintenance.)

    Specifically, I want to handle cases where my strategy is in, say, a long position (that was submitted via EnterLong()) on Friday at market close. Also submitted and working/accepted is a profit target via SetProfitTarget().

    Now my data connection disconnects and with it the strategy is disabled (correct?).

    After the server maintenance, I re-connect to CQG and want to re-enable the strategy in such a way that it goes back to the state it was in on Friday at market close. I.e. long position is open, and profit target is submitted.

    Which StartBehavior will do that? I've tried "Wait until flat" and "Adopt account position" which both didn't achieve what I need.

    Many thanks!

    #2
    Additional question:

    On https://ninjatrader.com/support/help..._positions.htm under "Immediately submit, synchronize account" it says

    * A previously generated order is considered to match an active strategy order when the order action, order type, quantity, limit price, and stop price are exactly identical.
    What if a strategy enters a position and then the data feed disconnects. Is the order that entered this position considered "a previously generated [strategy] order" in the sense of above's quote?

    What if not only the data feed disconnects but NinjaTrader is shut down and restarted?

    Regards!

    Comment


      #3
      Hello yannickwe,

      For maintenance the best case would be to program a time/date condition to close the position before the known disconnect. The start behavior controls how orders are submitted when a strategy starts and if it will try to sync with the account or bring the account in sync with the strategy. Using a start behavior to control the account position can be very complicated and relies heavily on how your specific strategy is created. The strategy may be able to resume the position so long as it historical calculates the exact same orders that generated that position and resumbits them so it can resume them. If it does not do that it may cancel any active targets and leave an open position and start out of sync. A previously generated order would be an order the strategy previously generated when it was running. If the platform is restarted that would also require the start behavior to run when the strategy is restarted.

      Comment


        #4
        Hi Jesse,

        Thanks!

        I don't quite understand your point.

        Are you saying you would choose a different start behavior than "Immediately submit, synchronize account" for the case I outlined (I'm happy to give more info, just tell me what you need to know)?

        And I fear I fail to understand this sentence

        A previously generated order would be an order the strategy previously generated when it was running. If the platform is restarted that would also require the start behavior to run when the strategy is restarted.
        As far as I see it, there is no way to start a strategy without choosing a start behavior. Instead, my question was whether NinjaTrader keeps a log of trades that spans data feed disconnects and session restarts. In other words, will NinjaTrader/the strategy be able to know/check what orders had been submitted by the strategy before NinjaTrader was restarted?

        Many thanks!

        Comment


          #5
          Hello yannickwe,

          I can't suggest a specific start behavior besides using the default of wait until flat, using different start behaviors requires that you go through the help guide documentation and compare that to what you coded or to code the strategy specifically with one behavior in mind. You would have to run tests to confirm your strategy actually works with the behavior you pick.

          Because of that the best solution is to avoid the behavior entirely by setting up conditions to exit the trade before the disconnect so when you reconnect the account is flat and the strategy can restart completely.

          A previously generate order is an order generated from a strategy. If your strategy does not exactly re create that order during processing the order is cancelled which could leave positions unprotected. This is what would require your testing to make sure your strategy works identically in historical and realtime.

          Comment


            #6
            Thanks.

            I might be misunderstanding, but I think the second question is still unanswered:

            Does NinjaTrader keep a log of trades across data feed disconnects and session restarts? In other words, is NinjaTrader/the strategy able to know/check what orders had been submitted by the strategy before NinjaTrader was restarted, or the data feed disconnected?

            PS
            Closing positions before each disconnect is not an option for a swing trading system such as the one in question

            Comment


              #7
              Hello yannickwe,

              The platform knows which was a strategy based order, that is not something you can check in the platforms trade performance information. A previously generated order is an order that a strategy generated.

              Comment


                #8
                Okay, with all due respect, you don't answer the questions that were asked.

                My question is whether the platform knows about orders across a system restart/data feed disconnect? Or only as long as NinjaTrader is kept open/the data feed is kept connected?

                Comment


                  #9
                  Hello yannickwe,

                  Yes the platform knows which was a strategy order, that is how the start behavior works to know if a previously generated order needs cancelled or mapped.

                  Comment


                    #10
                    Thank you!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    116 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    61 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    40 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    43 views
                    0 likes
                    Last Post TheRealMorford  
                    Started by Mindset, 02-28-2026, 06:16 AM
                    0 responses
                    82 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Working...
                    X