• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


Unmanaged: recovering from connection loss

  • Filter
  • Time
  • Show
Clear All
new posts

    Unmanaged: recovering from connection loss


    This is an old subject but since NT7 has addressed several issues with its updates, I'd like to know the last state in regards to connection loss, primarily under unmanaged approach.

    If I have an opened position, plus a far stoploss order and a working limit order,then suddenly a "temporary connection loss" ( temporary as non completed disconnection ) , and I've set previously: keeprunning, so :

    1. When NT recovers from that temporary connection loss, everything runs seamlessly ?
    If NOT
    2. How to recover my active orders into my Strategy ?
    3. What if that limit order was filled when connection returns, but my strategy and account positions don't match ?

    Besides the answers to those question, any suggestion or practical suggestions will be appreciated.

    Thanks in advance
    Last edited by pstrusi; 03-01-2017, 01:08 PM.

    Hello pstrusi, and thank you for your questions.

    With regard to your first and second questions, these rely on a decision made by you. When a connection loss happens, it is possible for your strategy and account positions to get out of sync. Trades away from the currently traded price may execute on the trade desk, and your strategy may encounter a trade signal. In this event, you will need to decide whether your strategy is correct, or the trade desk is correct. Ninja will support you in either of these cases, and will correct the situation seamlessly (to answer your first question directly) upon reconnection. But you will have to decide what recovering orders means. Should your Account recover your Strategy's position, or should your Strategy recover your Account's position?

    So to answer your second question both ways, if you would prefer your strategy adopt your account's position, you should set up your strategy to Recalculate when you reconnect. If you would prefer your Account adopt your strategy's position, your strategy should immediately submit live working historical orders when it is turned on. Note that these options are not mutually exclusive. You can do both, in which case your strategy will interpret what has happened while it was disconnected before immediately taking corrective action and modifying your account position. Or you can do neither, having your strategy wait until your position is flat before running again, or continuing to run independently of whatever happened at the trade desk. You can even set up your strategy to disable completely and wait for you to come back at a later point, and even then, you can determine whether your orders cancel or not.

    In short, Ninja will do whatever you decide it should do.

    Your third question is explored in depth in this linked thread,


    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service


      Thank you very much Jessica for answering quite complete, I'll have to study what are my best options according to daytrading strategy. If an unsolved doubt rises, I'll ask you again to solve it.

      Best regards


        Hi Jessica,

        I'm trying "Recalculate option" for connection loss but still evaluating it.
        I'd like to know what are the process or logic flow that NT follows to "recalculate" from connection loss.

        1. NT retrieves my position account and live orders, then it recalculates the Strategy ?
        2. Could it be possible today ( with the new updates ) to code my own protocol ?
        3. Is NT8 different in something?
        4. Does NT8 allow you to do your own proccess ?

        Thanks in advance


          I will be happy to clarify further.

          To your first question, we have this from the help guide.

          Originally posted by http://ninjatrader.com/support/helpGuides/nt8/en-us/?connectionlosshandling.htm
          When using ConnectionLossHandling.Recalculate, recalculations will only occur if the strategy was stopped based on the conditions below. Should the connection be reestablished before the strategy was stopped, the strategy will continue running without recalculating as if no disconnect occurred.
          • If data feed disconnects for longer than the time specified in DisconnectDelaySeconds, the strategy is stopped.
          • If the order feed disconnects and the strategy places an order action while disconnected, the strategy is stopped.
          • If both the data and order feeds disconnect for longer than the time specified in DisconnectDelaySeconds, the strategy is stopped.
          To your second and fourth questions, I have submitted a feature request to the product management team for the following feature :

          This customer would like to be able to code custom connection loss handlers
          I will follow up with more information as soon as it's available. If the feature requests already exists, a vote will be added to it.

          To your third question, while NT8 is similar to NT7 the way it functions, some options have been moved around. For example, several syncing and autostart options have been combined into your strategy's Start Strategy.

          Please let us know if there are any other ways we can help.
          Jessica P.NinjaTrader Customer Service


            Hello pstrusi,

            This feature is being reviewed by the product management team and has been assigned the following unique tracking ID


            Please note that NinjaScript does have an OnConnectionStatusUpdate call, which will allow you to specify what your script does once reconnected. This is covered here,


            The feature request would cover adding connection loss handlers to the strategy properties menu, and allow you to control what happens before and after your strategy is disabled.

            Please let us know if there is any other way we can help.
            Jessica P.NinjaTrader Customer Service


              Thank you very much Jessica


                Since It's been quite some time and NT7 has gotten some fix, I'd like to know if now it's possible to sync Account's Position to Strategy's Position after a recover from connection-loss? Generally speaking, pretty often they got out of sync and remained that way until user intervention of course.

                So, consider this situation:

                Your Strategy is working and totally synced with your Account's position ( at your broker ), then your Strategy submitted an order that is "working", suddenly a connection-loss happened; after a couple of minutes you recovered your connection and realized that the last working order got filled, therefore your Account's position is different now, so here the questions:

                1. When the connection-recover happens, Does the Strategy automatically update its live orders and Strategy's position, if Sync=True or is this just for the startup ?
                2. If I'd like this action to happen: what's the recommendation: "Keep running" or "Recalculate" ?
                3. If any of above is possible, how can I write my own method to handle my recovers in NT7 ?

                Last edited by pstrusi; 07-16-2018, 10:40 AM.


                  Hello pstrusi,

                  Thank you for your post.

                  Adopting the Account's Position is not an option in NinjaTrader 7 but is an option in NinjaTrader 8. You can find information on the option at the following link: https://ninjatrader.com/support/help...ccountPosition
                  1. The Strategy would push it's calculated Position to the Account upon re-connect if the 'Sync Account Position' option was set to True and the Recalculate option was used for the 'On connection loss' setting under the NinjaTrader 7 Control Center > Tools > Options > Strategies > NinjaScript menu.

                    Think of the Strategy as being disabled and re-enabled if you use Recalculate.

                    If the Strategy is not set to Recalcualte then it is set to either Keep Running or Stop Strategy.

                    In the scenario you detailed in your latest post the following would happen for each option:
                    • Using Keep Running would result in the Strategy ignoring the disconnect and not re-calculating or syncing it's Position.
                    • Using Stop Strategy would mean the Strategy stopped running all together.

                    These options are detailed at the following link under 'Understanding the NinjaScript tab' > 'On Connection Loss': https://ninjatrader.com/support/help...tegies_tab.htm

                  2. You should test these options and understand their functionality. If you want the Strategy to push it's recalcualted Position to the account per the 'On connection loss' settings then Recalcualte is the option you need to use along with the 'Sync Account Position' option set to True.

                  3. There is no supported means to create your own behavior for this.

                  Please let me know if you have any questions.
                  Patrick H.NinjaTrader Customer Service


                  Latest Posts


                  Topics Statistics Last Post
                  Started by Swing123, Today, 03:09 AM
                  0 responses
                  Last Post Swing123  
                  Started by Antares66, Yesterday, 05:19 PM
                  1 response
                  Last Post NinjaTrader_ChrisSch  
                  Started by lavalampmj, Yesterday, 05:25 PM
                  0 responses
                  Last Post lavalampmj  
                  Started by jmneto, Yesterday, 05:18 PM
                  0 responses
                  Last Post jmneto
                  by jmneto
                  Started by Bobbyj78, Yesterday, 02:21 PM
                  2 responses
                  Last Post bltdavid