Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Best Practices to Mitigate "Connection Lost" ?

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

    Best Practices to Mitigate "Connection Lost" ?

    NinjaTrader Ninjas,

    I was wondering if any moderator or fellow member had developed a best practice or recommendation for dealing with the Connection Lost condition for your broker. This happens from time to time for various reasons. It recently happened to me which left me with an uncovered position. After reading up on the topic, I learned why it happened that way:
    1. I had an active strategy running with an open position and associated profit target and stop loss orders (managed approach). StartBehavior was WaitUntilFlat
    2. I had my disconnect delay setting set to 10 seconds
    3. Connection Loss Handling was set to Recalculate

    The connection to my broker was lost for more than 10 seconds (no apparent reason), and strategy was disabled (as designed per settings). When it was ReCalculated the WaitUntilFlat behavior cancelled all profit target and stop loss orders (also per the NinjaTrader manual documentation). While all this occurred how the program is designed, it was certainly an unintended situation (due to my ignorance and lack of foresight).

    Other than the standard disclaimer that we should always monitor active strategies, which I did, I was wondering if anyone had a best practice in place to mitigate this situation?

    Here are a few options I can think of:

    1. Set the disconnect delay to a longer time period (on the order of minutes). I think the strategy would keep running for nuisance disconnects shorter than the designated time period. Is this correct?

    2. Set the Start Behavior to Immediately Submit or Immediately Submit, Synchronize Account. Upon reconnection, and Strategy ReCalculation I think this would adopt the profit target and stop loss orders as long as they matched the historical calculated entry orders. The main risk I see here is that upon recalculation, the historical data does not exactly match and the orders may be cancelled. Any thoughts or lessons learned?


    3. Set Connection Loss Handling to "Keep Running". While I'm sure this will keep the strategy running, strategy events have the potential to trigger in the disconnected time period. You may still have an out of sync position if the strategy submits orders while disconnected. Anybody had luck with this setting?

    4. Keep a "backup" market data connection. Obviously this won't help if the root cause is your internet connection, but may help if the issue is with the primary market data connection. Do strategies auto-revert and/or calculate on the "next available" real-time and historical connection if the primary/preferred connection is lost? Or will the strategy be disabled per the Strategy disconnect delay settings on the connected data feed on which the strategy was activated?


    Anything else you have found to mitigate nuisance lost connection errors?

    Thanks in advance for your time,

    Kevin

    #2
    Hello whizkpm,

    This heavily depends on a few unique factors to your strategy and internet connection so there is likely not 1 best practice here to follow. The start behavior that you use depends on how you programmed the strategy. Changing from WaitUntilFlat requires that you confirm your logic works with the start behavior that you select. Using other start behaviors without doing this confirmation could leave you in a worse situation than you had described, for example entering other unwanted positions.

    Changing the connection loss settings depends on the disconnects that you see while using your connection, if they are short you can increase the settings to accommodate that. If they are long you may want to opt for using keep running and a much longer disconnect setting however that can also be bad depending on how long the disconnect was for. If the strategy is left to keep running and you miss a lot of market data that could prevent the strategy from working right or having incorrect calculations once it resumes.

    A backup connection would only be helpful for data, if the account connection is disconnected the strategy still wont be able to work. the connection for the strategies selected account needs to be connected for it to work in realtime. If the account connection is physically disconnected meaning you have to manually reconnect there is no recourse at that point, you need to reconnect and re enable the strategy.

    If you commonly see disconnects an alternate option would be to host NinjaTrader on a VPS service which has a more stable internet connection.

    Comment


      #3
      Jesse,

      Thanks for your explanation. I'm confident I can find a way forward now with a better understanding of the risks for each method.

      Cheers,

      Kevin

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      111 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      60 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      38 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
      79 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X