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

Need to trigger alert on data feed disconnect.

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

    Need to trigger alert on data feed disconnect.

    I'm having problems with intermittent data feed disconnects on my production machine. Often I launch Remote Desktop only to discover that my feed has been disconnected for hours and that all my strategies are offline. TOXIC situation as you can imagine. I tried to sort it out with my data feed provider as well as my hosting company and you know how that usually goes - ping pong and everyone points at the other side.

    Be this as it may I need to find out a way to alert myself when I get a disconnect which gets to the point of suspension of my strategies. What would be best is some kind of heartbeat that I can run in an indicator/strategy and when things go offline it sends me an email or text message (I have already libs for both).

    So my question: Is there some Ninjascript API call that can catch those disconnects? Not the temporary ones but one that can get called when Ninja suspends all open strategies due to an extended data feed outage?

    Any tips/hints/suggestions welcome. Thanks in advance!

    #2
    You can use the OnConnectionStatus event to monitor the datafeed/price feed connection:


    If the ConnectionStatus.Disconnected, you can issue an alert.

    Which would be different the a ConnectionStatus.LostConnection which is the temporary connection which should reconnect.

    You can also re-configure the disconnect handling under 'On Connection Loss' and the number of seconds it waits or retries before considering the connection terminal:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Thanks

      Alright - that sounds like what I have in mind. I'll hack something up tomorrow and let you know if I run into problems.

      Comment


        #4
        Follow up question

        A quick follow up question - per your suggestion: IF the data feed is disconnected then is the OnConnectionStatus() method even being called? One would thing that the bar update just stops, right?

        Originally posted by NinjaTrader_Matthew View Post
        You can use the OnConnectionStatus event to monitor the datafeed/price feed connection:


        If the ConnectionStatus.Disconnected, you can issue an alert.

        Which would be different the a ConnectionStatus.LostConnection which is the temporary connection which should reconnect.

        You can also re-configure the disconnect handling under 'On Connection Loss' and the number of seconds it waits or retries before considering the connection terminal:

        http://www.ninjatrader.com/support/h...tegies_tab.htm

        Comment


          #5
          OnConnectionStatus is called every time there is a change to the connection. This means you should get a call to this method as soon as the connection goes from connect-> connections loss or disconnected (however only once)

          You are correct that OnBarUpdate would not fire if you were not connected as there would not be any incoming ticks, so if you want to check that at some interval, you can implement your own timer which would call OnConnectionStatus. This can be implemented using the TriggerCustomEvent method:

          MatthewNinjaTrader Product Management

          Comment


            #6
            Originally posted by NinjaTrader_Matthew View Post
            OnConnectionStatus is called every time there is a change to the connection. This means you should get a call to this method as soon as the connection goes from connect-> connections loss or disconnected (however only once)

            You are correct that OnBarUpdate would not fire if you were not connected as there would not be any incoming ticks, so if you want to check that at some interval, you can implement your own timer which would call OnConnectionStatus. This can be implemented using the TriggerCustomEvent method:

            http://www.ninjatrader.com/support/h...ustomevent.htm
            Okay, if I understand it correctly then the call to check the param from within the OnBarUpdate method as in the example is really not necessary. All I would need to do is to override the OnConnectionStatus method and monitor for DisconnectionStatus.Disconnected. If it's true then send me an email - done. Do you concur? ;-)

            Comment


              #7
              Yes, that should do the trick. What you can do as a quick exercise is add the following

              Code:
              		protected override void OnConnectionStatus(ConnectionStatus orderStatus, ConnectionStatus priceStatus)
              		{
              			Print(DateTime.Now + " OnConnectionStatus" + orderStatus + " " + priceStatus);
              		}
              Then kill your connection to NinjaTrader using something like TCPView and check that these are being called and updated as you expect, and then amend your logic to account for the results you see after a connection loss/disconnect.
              MatthewNinjaTrader Product Management

              Comment


                #8
                Sorry but now I think I lost you there. What is it you are suggesting via TCPView? My plan is to simply get a notification via email so that I KNOW that Ninja is down and I can RDP into my system and restart the connector.

                Are you saying there may be a way of automating that? Like - if data feed craps out automate the process of reconnecting?

                Originally posted by NinjaTrader_Matthew View Post
                Yes, that should do the trick. What you can do as a quick exercise is add the following

                Code:
                		protected override void OnConnectionStatus(ConnectionStatus orderStatus, ConnectionStatus priceStatus)
                		{
                			Print(DateTime.Now + " OnConnectionStatus" + orderStatus + " " + priceStatus);
                		}
                Then kill your connection to NinjaTrader using something like TCPView and check that these are being called and updated as you expect, and then amend your logic to account for the results you see after a connection loss/disconnect.

                Comment


                  #9
                  No, you cannot automate the reconnect process in NT7. I'm saying, as you are developing your alert mechanism, you can use a tool like TCPView to test the behavior you're trying to implement to ensure that it works like you expect. Rather than having to wait for a 'natural' disconnect, you can force the connection closed using TCPView by Windows Sysinternals

                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    Originally posted by NinjaTrader_Matthew View Post
                    No, you cannot automate the reconnect process in NT7. I'm saying, as you are developing your alert mechanism, you can use a tool like TCPView to test the behavior you're trying to implement to ensure that it works like you expect. Rather than having to wait for a 'natural' disconnect, you can force the connection closed using TCPView by Windows Sysinternals

                    http://technet.microsoft.com/en-us/s.../bb897437.aspx
                    Aaaah - I get you now - good thinking. HOWEVER unfortunately it seems that I get plenty of opportunities each day. I can just start testing with regular/brief disconnects and then just exclude those and leave the final ones once I know it works.

                    Comment


                      #11
                      Does this work in an indicator?

                      I just got this error message:

                      Indicator\Heartbeat.cs 'NinjaTrader.Indicator.Heartbeat.OnConnectionStatu s(NinjaTrader.Cbi.ConnectionStatus, NinjaTrader.Cbi.ConnectionStatus)': no suitable method found to override.

                      Thanks for any input.

                      Comment


                        #12
                        OnConnectionStatus is not available from an indicator, you must override the method in your strategy directly
                        MatthewNinjaTrader Product Management

                        Comment


                          #13
                          I'm having problems with intermittent data feed disconnects on my production machine.
                          I hope to be starting on automated trading very soon and I'm terrified of Virgin Media here in the UK disconnecting me when I'm autotrading, as they seem to get a kick out of doing this.

                          I'm seriously looking at using a colocated computer near the exchange (IOW, VPS).

                          The broadband and power supplies on VPS will always be far more secure than in a domestic environment.

                          Whether VPS can signal you remotely when down, I don't know but it may be possible.

                          Just an idea.

                          Comment


                            #14
                            Originally posted by arbuthnot View Post
                            I hope to be starting on automated trading very soon and I'm terrified of Virgin Media here in the UK disconnecting me when I'm autotrading, as they seem to get a kick out of doing this.

                            I'm seriously looking at using a colocated computer near the exchange (IOW, VPS).

                            The broadband and power supplies on VPS will always be far more secure than in a domestic environment.

                            Whether VPS can signal you remotely when down, I don't know but it may be possible.

                            Just an idea.
                            I actually am doing just that - my production system is a monster with 32GB of RAM sitting in a professional data center. Dual power systems, routers, network monitoring, the works. And my data feed still drops mysteriously - I have alert systems set up but they only kick in if the network goes down. NOT when Kinetick suddenly drops off for whatever reason - I could never figure out why it does happen and frankly I have given up trying.

                            I just wrote that strategy and have deployed it - it should send me an email next time things go bust. Should be easy for you to do put together something similar. Don't rely on networking and hosting providers - they can only do so much. I have covered all angles on the networking side - frankly I don't think it's humanly possible to setup a more stable and monitored system than mine. And I'm still facing constant data feed disconnects.

                            Comment


                              #15
                              Thanks very much, Molecool. I was fascinated to read what you had to say.

                              I was thinking "Once I've got my strat running on a colocated PC in a data center, it'll be easy-peasy. What can go wrong?"

                              Now I know.

                              I'm even tempted now to run my strats from home, given that I'm only 150 miles from FXCM's London office so the time lag is really minimal.

                              Much obliged.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by naanku, Today, 07:25 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post naanku
                              by naanku
                               
                              Started by milfocs, Today, 07:23 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post milfocs
                              by milfocs
                               
                              Started by PaulMohn, Today, 06:59 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post PaulMohn  
                              Started by bortz, 11-06-2023, 08:04 AM
                              48 responses
                              1,753 views
                              0 likes
                              Last Post carnitron  
                              Started by Jonker, 04-27-2024, 01:19 PM
                              3 responses
                              24 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X