Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

best practice to handle the connection loss

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

    best practice to handle the connection loss

    I have a strategy that is always in the market. I mean if there is a long position and when the stop is trigger, it would exit the long position and enter the short position, vice versa. Today I found out it didn't exit the existing long position and short. I checked the log. Here is the log
    2/27/2025 7:20 Default Disabling NinjaScript strategy 'SelTimeDSTV2/352009544'
    2/27/2025 7:20 Default Strategy 'SelTimeDSTV2/352009544' lost price connection for more than 10 seconds and will be restarted.
    2/27/2025 7:20 Connection Using HDS (hds-us-nt-017.ninjatrader.com/31655)
    2/27/2025 7:20 Connection Connection lost to the NinjaTrader Historical Data Server: hds-us-nt-015.ninjatrader.com
    2/27/2025 7:20 Connection Live: Primary connection=Connection lost Price feed=Connection lost
    2/27/2025 7:20 Connection Live: Primary connection=Connected Price feed=Connection lost

    The weird thing is I have two computers using the same wifi. One works fine without the connection loss. Another one has the connection loss. Is it the issue of the computer itself.

    Another question is what the best practice to handle my scenario. I mean I want to the strategy to resume running after the connection restores. Currently, the connection loss handling is set to be recalculate the strategy.

    #2
    Hello Playdc,

    You can adjust the 'Handling' to 'Keep Running', and adjust the 'Disconnect delay seconds', 'Number of restart attempts', and 'Restarts within x minutes'.

    Tools -> Options -> Strategies -> NinjaScript.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you, ChelseaB. One more question, what are the good numbers to set 'Disconnect delay seconds', 'Number of restart attempts', and 'Restarts within x minutes'?

      Comment


        #4
        Hello Playdc,

        This will depend on what you are experiencing.

        If connection is lost for 10 seconds or less set 'Disconnect delay seconds' to 10. If the connection losses are longer use a higher value.

        If you want any amount of reconnection attempts within x minutes, use a high number like 9999 reconnection attempts.

        Use a small value for 'Restarts within x minutes' to require a large amount of reconnection attempts within a short amount of time which is less likely.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Suppose I set Disconnect delay seconds' to 10, amount of reconnection attempts within x minutes to be 10 in 5 minutes. Does it mean after all 10 attempts in 5 minutes fail, then my strategy would be disabled?

          Comment


            #6
            Hello Playdc,

            Yes, this is correct.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              What is the difference between recalculating and keep running when the connection lost happens?.

              Comment


                #8
                Hello Playdc,

                When using Recalculate the script reloads and re-runs through historical data to confirm the position. This is would be the same as if you had right-clicked a chart and selected Reload NinjaScript.

                When using Keep running the strategy will resume as if nothing had happened.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Suppose here is a scenario. The strategy enters a long position, after a while, the connection lost happens, within the minutes and the attempts set up, the connection resumes. Here are two scenarios about what happens during the connection lost period.

                  scenario 1: there is no enter short signal generated by the strategy during that period;
                  scenario 2: there is one enter short signal generated by the strategy during that period.

                  Could you please elaborate what would happen for these two scenarios using recalculate and keep running respectively?

                  Comment


                    #10
                    Hello Playdc,

                    With Recalculate the strategy would process the historical data. If the strategy has a short position when the historical data is calculating the position will be short.

                    With keep running the position would be long.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      So you mean if it is recalculate when the connection restore, recalculate from historical data the strategy misses, even the short signal should be issued during the data lost period, it would issue the short signal immediately. If it is keep running, it would only calculate based on real time data, so the short signal would be ignored.

                      Comment


                        #12
                        Originally posted by Playdc View Post
                        So you mean if it is recalculate when the connection restore, recalculate from historical data the strategy misses, even the short signal should be issued during the data lost period, it would issue the short signal immediately. If it is keep running, it would only calculate based on real time data, so the short signal would be ignored.
                        Hi Chelsea,

                        Is my understanding of the difference between recalculate and keep running correct?

                        Comment


                          #13
                          Hello Playdc,

                          Yes, if the strategy has a short position when the historical data has finished calculating the position will be short.

                          With keep running the historical data will not be reprocess and the strategy will have the same position.
                          Chelsea B.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by NullPointStrategies, Today, 05:17 AM
                          0 responses
                          39 views
                          0 likes
                          Last Post NullPointStrategies  
                          Started by argusthome, 03-08-2026, 10:06 AM
                          0 responses
                          124 views
                          0 likes
                          Last Post argusthome  
                          Started by NabilKhattabi, 03-06-2026, 11:18 AM
                          0 responses
                          64 views
                          0 likes
                          Last Post NabilKhattabi  
                          Started by Deep42, 03-06-2026, 12:28 AM
                          0 responses
                          41 views
                          0 likes
                          Last Post Deep42
                          by Deep42
                           
                          Started by TheRealMorford, 03-05-2026, 06:15 PM
                          0 responses
                          46 views
                          0 likes
                          Last Post TheRealMorford  
                          Working...
                          X