Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Monitoring the data connection

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

    Monitoring the data connection

    Hi,

    I need to monitor my data feed for disconnection. For whatever reason my broker's servers are sometimes completely unavailable for a few minutes at night (eastern time zone). I would like to send myself an email and/or generate a looping sound to notify me that NT is unable to act on (protective stop) orders while I am sleeping with open positions.

    I know how to email myself alerts and play sounds but I don't know what to use to monitor the data feed.

    Can this be done? If so, what functions/methods/etc should I be looking at?

    Thanks in advance.

    -mp

    #2
    mp, you can monitor OnConnectionStatus() for these tasks - http://www.ninjatrader.com/support/h...tionstatus.htm

    Comment


      #3
      Marcus this might give you some ideas:

      PHP Code:
      #region OnConnectionStatus()
      protected override void OnConnectionStatus(ConnectionStatus orderStatus, ConnectionStatus priceStatus)
      //This method is caled once for every change in connection status
       
      {//Open OnConnectionStatus()
       
      priceDataFeed = priceStatus;
      orderDataFeed = orderStatus;
       
      Print(DateTime.Now + " Connection '" + Bars.MarketData.Connection.Options.Provider.ToString() + "' Order Server: "
      + orderStatus + ". Price Server: " + priceStatus + ".");
       
      if (orderDataFeed == ConnectionStatus.ConnectionLost && alertsWindow) Alert("orderconnectionlost", NinjaTrader.Cbi.Priority.High, "Order Server Connection Lost", "triple_klaxon.wav", 10, Color.Red, Color.White);
      if (priceDataFeed == ConnectionStatus.ConnectionLost && alertsWindow) Alert("priceconnectionlost", NinjaTrader.Cbi.Priority.High, "Price Server Connection Lost", "triple_klaxon.wav", 10, Color.Red, Color.White);
      if (priceDataFeed == ConnectionStatus.Connected && orderDataFeed == ConnectionStatus.Connected && alertsWindow) Alert("connectionsOK", NinjaTrader.Cbi.Priority.Low, "Price and Order Server Connected", "Connected.wav", 10, Color.Green, Color.White);
       
      // NOTE: If you connect to a second data source or broker, the connection name will always refer to the primary connection.
      // That is a Known Issue with NT as of NT7b15.
       
      }//CloseOnConnectionStatus
      #endregion 
      
      Remember to declare these in the Variables region first:
      PHP Code:
      private ConnectionStatus priceDataFeed = ConnectionStatus.Connected;
      private ConnectionStatus orderDataFeed = ConnectionStatus.Connected; 
      
      Change wav files as appropriate.

      Comment


        #4
        NinjaTrader_Bertrand: thank you for the info.
        MXASJ: Thanks a lot! I was not expecting a ready made solution...

        Comment


          #5
          Code:
          [FONT=Courier New][COLOR=#007700]if ([/COLOR][COLOR=#0000bb]orderDataFeed [/COLOR][COLOR=#007700]== [/COLOR][COLOR=#0000bb][B][COLOR=#282828]ConnectionStatus[/COLOR][/B][/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]ConnectionLost [/COLOR][COLOR=#007700]&& [/COLOR][COLOR=#0000bb]alertsWindow[/COLOR][COLOR=#007700]) [/COLOR][COLOR=#0000bb]Alert[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"orderconnectionlost"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]NinjaTrader[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Cbi[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Priority[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]High[/COLOR][COLOR=#007700], [/COLOR][COLOR=#dd0000]"Order Server Connection Lost"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#dd0000]"triple_klaxon.wav"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]10[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]Color[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Red[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]Color[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]White[/COLOR][COLOR=#007700]);[/COLOR][/FONT]

          The alerts from the above code by MXASJ are not rearming after 10 seconds. How is it possible to get the alerts to re-arm? how would a looping command work especially if the connection is lost/disconnected? any suggestions?


          thanks in advance
          Last edited by dawdler; 05-30-2011, 10:34 AM.

          Comment


            #6
            any suggestions on how to re-arm an alert after a connection loss?

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            666 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            377 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            110 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            575 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            580 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X