Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategies lose connection and stop

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

    strategies lose connection and stop

    Hi,

    this has happened several times to me now:

    I have 3 strategies running. All use Kinetick as the datafeed (connection establishes on startup of NT). For execution the stragegies use:
    #1: SIM101 (NT internal)
    #2: InteractiveBrokers REAL money account (TWS for it is open)
    #3: InteractiveBrokers SIM account (TWS for this one is also open)

    For some reason the connection to IB's REAL money account gets lost and cannot be reestablished for several minutes. Only strategy #2 uses this account yet all 3 strategies are switched OFF with the message "Strategy 'abc' lost price connection for more than 10 seconds and will be restarted."

    But the price connection to Kinetick is still OK! I can see all ticks coming in. TWS for the SIM account is also running fine. Only the TWS for the REAL money account is down (& trying to reconnect).

    Why are all 3 strategies shutting down? Can this be prevented?

    Please be aware that I run all 3 strategies in UNMANAGED mode as configured here:
    Code:
    protected override void Initialize()
    {
        // Run on every tick
        CalculateOnBarClose = false;
                
        // Use UNMANAGED order methods
            Unmanaged = true;
                
        // Allows for custom OVERFILL handling
            IgnoreOverFill = true;
                
        // ### handling of CONNECTION LOSS
        DisconnectDelaySeconds = 10; // Disconnect has to be at least 10 seconds
        MaxRestartMinutes = 390; // Allow for restarting the strategy only if there were less restart attempts than MaxRestartAttempts within the last 6.5 hours
            MaxRestartAttempts = 4680; // Allow the strategy to restart every 5 seconds for 6.5 hours.
        ConnectionLossHandling = ConnectionLossHandling.Recalculate; // Strategy will attempt to recalculate its strategy position when a connection is reestablished.
        RestartDelaySeconds = 5; // Recalculate strategy only after connection is reestablished for at least 5 seconds
                
        // for debugging
        logTrades = true;
        TraceOrders = true;
        // traces are generated and displayed in the NinjaScript Output window
        // for each call of an order method providing confirmation that the method is entered
        // and providing information if order methods are ignored and why. 
    }
    Please advise, thanks!

    NutFlush

    #2
    Hello NutFlush,

    If you are connected to multiple Data Providers/Brokers at once like Kinetick, IB, and another IB when you get a disconnect on one connection NinjaTrader's Connection Loss handing will trigger which is causing this to disable your strategies due to your Connection Loss settings.


    Happy to be of further assistance.
    Last edited by NinjaTrader_JC; 12-13-2013, 03:03 PM. Reason: Clarifing
    JCNinjaTrader Customer Service

    Comment


      #3
      Thanks JC,

      I was under the impression that the settings in Initialize() override the general settings from the Tools menu. Therefore I included this:

      MaxRestartAttempts = 4680; // Allow the strategy to restart every 5 seconds for 6.5 hours.

      Now I am wondering if the individual settings in each strategy are used at all.

      Could you please clearify?

      Thanks,
      NutFlush

      P.S. I just checked the settings in the Tools menu:
      - Disconnect delay seconds: 3600
      - Number of restart attempts: 999
      - Restarts within x minutes: 1

      Since the error message said there was no connection for 10 seconds the setting inside the strategies appears to have been used, but not the number of restarts???
      Last edited by NutFlush; 12-13-2013, 01:24 PM.

      Comment


        #4
        Hello NutFlush,

        Correct, setting these parameters inside of the Initialize() it will overwrite the settings inside of this windows.

        Let me try to clarify, so since you are setting your strategy to "Recalculate" and the "Disconnect delay seconds" is only 10 seconds this means that NinjaTrader will log this as a full disconnect. Using "Recalculate" and the data feed disconnects for longer than the time specified in “Disconnect delay seconds”, the strategy is stopped.

        If you are experiencing long disconnects then you may want to increase the "DisconnectDelaySeconds" inside of Initialize() so NinjaTrader will not stop your strategy.

        Happy to be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi JC,

          your proposal sounds good. Will try that!

          I would be great if in future releases the behavior of strategies would be changed so that only the strategies that actually utilize a data feed or a brokerage connection are affected from a disconnect. Makes no sense to me that ALL strategies are stopped even if they don't need the interrupted connection.

          Thanks,
          NutFlush

          Comment


            #6
            Hello NutFlush,

            It is on our feedback list for NinjaTrader 8, and I will send in your vote for this as well.

            Happy to be of further assistance.
            JCNinjaTrader Customer Service

            Comment


              #7
              Thanks JC,

              just one follow-up question: if I have 2 strategies running with #1 being unmanaged and having the setting in Initialize() of "Disconnect delay seconds: 3600" will it keep on running independently of the settings in strategy #2? Or will #2 potentially cause ALL strategies to stop?

              Examples:
              a) #2 is NOT unmanaged and the default setting in TOOLS is 10 seconds
              b) #2 is ALSO unmanaged, but has a shorter setting (i.e., "Disconnect delay seconds: 15")

              Suppose the connection is gone for 50 seconds, will strategy #1 still be running (I assume that #2 will be stopped by then)? Or will #2 stop both strategies?

              Thanks,
              NutFlush

              Comment


                #8
                Hello,

                The strategies will each have their own DisconnectDelaySeconds. Even though it is a global property the strategies will each operate independently using their initialized values regardless of managed or unmanaged.

                Let me know if I can further assist
                LanceNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Lance View Post
                  Hello,

                  The strategies will each have their own DisconnectDelaySeconds. Even though it is a global property the strategies will each operate independently using their initialized values regardless of managed or unmanaged.

                  Let me know if I can further assist
                  Hi Lance,

                  thanks for your input. If I understand you correctly, the fact that one strategy turns off does NOT influence the other strategies, as these will decide whether or not to turn off solely based on their individual settings.

                  Is my understanding correct?

                  Thanks,
                  NutFlush

                  Comment


                    #10
                    Yes that is correct.

                    Let me know if I can further assist.
                    LanceNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by kmunroe478, Yesterday, 05:39 PM
                    2 responses
                    14 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by kevinenergy, 02-17-2023, 12:42 PM
                    115 responses
                    2,699 views
                    1 like
                    Last Post kevinenergy  
                    Started by prdecast, Today, 06:07 AM
                    1 response
                    4 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by Christopher_R, Today, 12:29 AM
                    1 response
                    14 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by chartchart, 05-19-2021, 04:14 PM
                    3 responses
                    577 views
                    1 like
                    Last Post NinjaTrader_Gaby  
                    Working...
                    X