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

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
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Marcus this might give you some ideas:

      PHP Code:
      #region OnConnectionStatus()
      protected override void OnConnectionStatus(ConnectionStatus orderStatusConnectionStatus 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 && alertsWindowAlert("orderconnectionlost"NinjaTrader.Cbi.Priority.High"Order Server Connection Lost""triple_klaxon.wav"10Color.RedColor.White);
      if (
      priceDataFeed == ConnectionStatus.ConnectionLost && alertsWindowAlert("priceconnectionlost"NinjaTrader.Cbi.Priority.High"Price Server Connection Lost""triple_klaxon.wav"10Color.RedColor.White);
      if (
      priceDataFeed == ConnectionStatus.Connected && orderDataFeed == ConnectionStatus.Connected && alertsWindowAlert("connectionsOK"NinjaTrader.Cbi.Priority.Low"Price and Order Server Connected""Connected.wav"10Color.GreenColor.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 PaulMohn, Today, 03:49 AM
            0 responses
            4 views
            0 likes
            Last Post PaulMohn  
            Started by inanazsocial, Today, 01:15 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by rocketman7, Today, 02:12 AM
            0 responses
            10 views
            0 likes
            Last Post rocketman7  
            Started by dustydbayer, Today, 01:59 AM
            0 responses
            2 views
            0 likes
            Last Post dustydbayer  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            5 responses
            23 views
            0 likes
            Last Post trilliantrader  
            Working...
            X