Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Connection Lost Notification Code (not working)

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

    #16
    Ok to get the connected email to work, I moved the "connected" loop to after the dataFeed variable was set. Now that part works, so I can see when the order server is reconnected.

    Is there a way to set up a timed message, say the order server connection is down for more than 5 minutes, can I somehow set up an elapsed time loop to send a message reconfiming the order server connection is still down after 5 minutes?

    As for the corrected code that does work:

    Code:
    
            private ConnectionStatus dataFeed = ConnectionStatus.[COLOR="Red"]Disconnected[/COLOR];
    
    
            protected override void OnConnectionStatus(ConnectionStatus orderStatus, ConnectionStatus priceStatus)
            {
            if (dataFeed == ConnectionStatus.ConnectionLost)
                {
                SendMail("[email protected]", "[email protected]", "Connection Lost", "Order Connection Lost");
                SendMail("[email protected]", "[email protected]", "Connection to Order Server Lost!", "Please verify that the server's internet connection is still valid");
                PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert4.wav");
                }
            if (dataFeed == ConnectionStatus.Connecting)
                {
                SendMail("[email protected]", "[email protected]", "Connecting", "Trying to reestablish Connection");
                SendMail("[email protected]", "[email protected]", "Connecting", "Trying to reestablish Order Server connection");
                PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert4.wav");
                }
            dataFeed = orderStatus;
            if (dataFeed == ConnectionStatus.Connected)
                {
                SendMail("[email protected]", "[email protected]", "Connected", "Check that strategy is active");
                SendMail("[email protected]", "[email protected]", "Connected", "Connected");
                PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert4.wav");
                }
    
            }
    Last edited by RDPoS; 12-30-2010, 01:28 AM. Reason: added code

    Comment


      #17
      Hello,

      Correct this is correct, A connected state would not trigger after you start a strategy if you are already in a connected state, as an email is only sent when the state changes.

      Unfortunately there is nothing in NinjaTrader that works off timers, Everything works on OnBarUpdate and ticks recieved. Therefor it is possible to setup such a timer, however it is unsupported and would require more general c# logic to achieve.

      Let me know if I can be of further assistance.
      BrettNinjaTrader Product Management

      Comment


        #18
        Grrrr.

        At 21:24:53, PFG sent a message that maintenance would bring the server down around 21:30 Eastern.
        At 21:50:27, the server went down for maintenance, and still I received no notification email with the previously posted code.

        When I logged in at 23:48 I saw the order server connection was down.

        Why would I have not received a message now?

        Of course as soon as I restarted the connection, I got the messages as it should have.

        But why is this continuing to happen? I can't see why I wouldn't have gotten the ALERTS.

        Comment


          #19
          Hello,

          We have looked into and tested this. We have found something that may be affecting this and resolved it in the next release of NinjaTrader 7. Which we are doing internal testing on now which would mean a release would be soon. We have also made a bunch of PFG API changes in general.

          Therefor please test with the Release 2 when it comes out here soon.
          BrettNinjaTrader Product Management

          Comment


            #20
            Looking forward to this.

            Comment


              #21
              Hey guys,
              I'm looking to do the same thing....be notified when my ConnectionStatus changes. Has this been resolvd and working now? If so, would you mind sharing the code?
              Thank you.

              Travis

              Comment


                #22
                Hello,

                Thanks for the post.

                FYI-> This thread is over 1 1/2 years old. However I can answer with you can use the following method to get Connection Loss events.



                Let me know if any questions.
                BrettNinjaTrader Product Management

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                637 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                366 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                107 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                569 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                571 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X