Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mestor, 03-10-2023, 01:50 AM
    16 responses
    388 views
    0 likes
    Last Post z.franck  
    Started by rtwave, 04-12-2024, 09:30 AM
    4 responses
    31 views
    0 likes
    Last Post rtwave
    by rtwave
     
    Started by yertle, Yesterday, 08:38 AM
    7 responses
    29 views
    0 likes
    Last Post yertle
    by yertle
     
    Started by bmartz, 03-12-2024, 06:12 AM
    2 responses
    22 views
    0 likes
    Last Post bmartz
    by bmartz
     
    Started by funk10101, Today, 12:02 AM
    0 responses
    7 views
    0 likes
    Last Post funk10101  
    Working...
    X