Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

connection lost options

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

    connection lost options

    Hi,

    I frequently find that when I return to my trade desk my connection to my broker's order server has been lost and I was told there is no way to have it auto-reconnect. So I was wondering, is there any way to at least have an email sent to me when it is disconnected, because I know my strategy can send me an email for an order placement. Is there such an option either in NT itself or a way to program a strategy to send me an email when the order server connection is lost or at least when the strategy tries to fill an order but the order is rejected because of a lost connection?
    [The data feed from my broker still comes in to the chart when I loose the connection so I'm assuming that it's not the data server but the order server connection that is lost -- although the bottom left tab with my broker's name is highlighted RED nonetheless.]

    Thank you.

    #2
    werido, this would be possible if you monitor for example OnConnectionStatus() in your strategy -

    Comment


      #3
      Thanks.
      So just changing the last line of code to make it send an email per bar that the order server is not connected would look like this:


      private ConnectionStatus dataFeed = ConnectionStatus.Connected;

      protected override void OnOrderUpdate(IOrder order)
      {
      if (dataFeed != ConnectionStatus.Connected)
      {
      SendMail("*******@gmail.com", "********@gmail.com", "Connection Lost", "Order Connection Lost");
      }
      }

      protected override void OnConnectionStatus(ConnectionStatus orderStatus, ConnectionStatus priceStatus)
      {
      dataFeed = orderStatus;
      }



      Does that look correct?

      Comment


        #4
        Looks good, werido. One thing to keep in mind is that the initial variable declaration is in the variables region, so it's not reset with bar updates or other events.

        private ConnectionStatus dataFeed = ConnectionStatus.Connected;
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hello,

          Looks correct to me.

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

          Comment


            #6
            Hi,

            This has helped notify me when the order server is disconnected and the price server is still connected because I put the notification under OnBarUpdate, so whenever there is a new bar and there is no order server connection, I get notified.

            But just recently my price server also became disconnected and that stops all notifications because there are no order or bar updates.

            So I was was wondering if there was a way to put dataFeed = priceStatus in addition to dataFeed = orderStatus in the code so that I can get an email notification when the price server becomes disconnected.

            The challenge here is to somehow have both the order server AND price server being checked to see if connected, and also to somehow drive the strategy to check for price server connection when there is (by definition) no OnBarUpdate.

            Is there any way to do this, or can dataFeed = ........... only have one thing assigned to it?

            Thanks.

            Comment


              #7
              werido, you can setup two variables to check for price and orderstatus - if you don't want to rely on OnBarUpdate(), check directly from OnConnectionStatus() which will be triggered on each connection event.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              65 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              41 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              23 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              26 views
              0 likes
              Last Post TheRealMorford  
              Started by Mindset, 02-28-2026, 06:16 AM
              0 responses
              52 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X