Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnConnectionStatusUpdate not working

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

    OnConnectionStatusUpdate not working

    Hi,

    I put this code in my indicator, to force a reload of all historical data if i lose my connection. However, it never works, as I never get the print statements to ouput, when i disconnect and reconnect my datafeed...

    Here is the code (which i found here https://ninjatrader.com/support/help...atusupdate.htm)

    Code:
    //monitor our connection status so our NinjaScript object would know to reload historical data
    //create a bool which tracks when historical data would need to be reloaded after a connection loss
    private bool IsReloadAllHistoricalDataNeeded = false;
    protected override void OnConnectionStatusUpdate(ConnectionStatusEventArgs connectionStatusUpdate)
    {           
      //if the connection status update detects a lost connection
      if(connectionStatusUpdate.Status == ConnectionStatus.ConnectionLost)
      {
        Print("Connection Lost, setting IsReloadAllHistorical Data to true");
        // switch the reload data bool to true           
        IsReloadAllHistoricalDataNeeded = true;
        
      
      }         
      // only if we needed to reload historical data && only after when we have reconnected
      else if (IsReloadAllHistoricalDataNeeded && connectionStatusUpdate.Status == ConnectionStatus.Connected )
      {
        Print("Connection is reconnected, reloading all historical data");
        //then reload data and set our bool back to false.
        ReloadAllHistoricalData();
        IsReloadAllHistoricalDataNeeded = false;
      }
      
    }

    #2
    Hello KhaosTrader, and thank you for your question.

    I would like to clarify, when you mention disconnecting and reconnecting your data feed, are you doing so through the control center's connections pull-down ? This will not produce a connection loss. To produce a connection loss, you will want to unplug an ethernet cable, disconnect from a wi-fi hotspot, or use a program such as the publicly available TcpView program. Ensure the last one comes from a microsoft URL with https at the beginning. This url should work for the time being :



    If you are creating a connection loss, as opposed to a disconnect, and your strategy is still not printing, or if we can help any other way, please let us know.
    Jessica P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    649 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    370 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    574 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    576 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X