Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ConnectionLossHandling Information and Alerting

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

    ConnectionLossHandling Information and Alerting

    Hello,

    I'm looking for more detailed information regarding ConnectionLossHandling in NT8. Here's what is in the Help Guide:
    ConnectionLossHandling.KeepRunning Keeps the strategy running. When the connection is reestablished the strategy will resume as if no disconnect occurred.
    ConnectionLossHandling.Recalculate Strategies will attempt to recalculate its strategy position when a connection is reestablished.
    ConnectionLossHandling.StopStrategy Automatically stops the strategy when disconnected for more than DisconnectDelaySeconds. No action will be taken when a connection is reestablished.
    StopStrategy is straightforward but I would like clarification on the other 2 options.

    KeepRunning
    Specifically, will OnBarUpdate be called for each bar that was "missed" while the connection was down? ( I'm using Calculate.OnBarClose )


    Recalculate
    What is the process that occurs upon restart? What is being "recalculated"?



    Also, is there a method called when a Connection Loss occurs that can be used to generate a custom alert?

    Thank you.

    #2
    Hello DharmaTrader,

    Thank you for the post.

    Keep running will not recalculate the historical data that has passed so it would just keep running once the connection resumes.

    Recalculate will re-run the OnBarUpdate for the historical bars effectively recalculating the strategies current position.

    You will see a difference in the log with these two settings during a connection event, with recalculating you will additionally see in the log:

    Disabling NinjaScript strategy 'strategyname'
    Enabling NinjaScript strategy ' strategyname '
    followed by the script reprocessing the historical bars before re-entering realtime.



    There is an override "OnConnectionStatusUpdate" which can be used for connection loss events.


    If you wanted to further visualize any of these settings, you can use the following code to print the events that are happening. You could just unplug/disconnect from the internet with the platform open to simulate a connection loss.

    Code:
    protected override void OnConnectionStatusUpdate(ConnectionStatusEventArgs connectionStatusUpdate)
    {
        if(connectionStatusUpdate.Status == ConnectionStatus.Connected)
        {
           Print("Connected at " + DateTime.Now);
        }
    
       else if(connectionStatusUpdate.Status == ConnectionStatus.ConnectionLost)
       {
          Print("Connection lost at: " + DateTime.Now);
       }
    }
    
    protected override void OnBarUpdate()
    {
        Print(CurrentBar + " OBU");
    }
    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    23 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    120 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    63 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
    45 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X