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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    90 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    137 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    120 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X