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)
//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; } }
Comment