Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to get an email when connection is lost?

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

    how to get an email when connection is lost?

    Would love to know what code and where it goes in order to receive an email when the API loses connection with the broker, or when an order is canceled.

    #2
    You can use OnConnectionStatus() and SendMail when reconnecting:



    Cancelled orders can be tracked with IOrder: http://www.ninjatrader-support.com/H...de.html?IOrder
    TimNinjaTrader Customer Service

    Comment


      #3
      I was trying to get a handle on how to receive an email when an order was filled. I understand the SendMail() part, but I don't quite follow the order filled part.

      Taking a part of my existing strategy

      Code:
                  // Condition set 1
                  if (DefaultInput[0] < ChandelierSAR(6, 4).Chandelier[0])
      			//	&& Time[0].DayOfWeek != DayOfWeek.Friday)
                  {
                      EnterLongStop(DefaultQuantity, ChandelierSAR(6, 4).Chandelier[0], "");
      				DrawDot("My dot" + CurrentBar, false, 0, ChandelierSAR(6, 4).Chandelier[0], Color.Blue);
                  }
      
                  // Condition set 2
                  if (DefaultInput[0] > ChandelierSAR(6, 4).Chandelier[0])
                  {
                      ExitLongStop(ChandelierSAR(6, 4).Chandelier[0], "", "");
      				DrawDot("My dot" + CurrentBar, false, 0, ChandelierSAR(6, 4).Chandelier[0], Color.Blue);
                  }
      Is it as simple as the following?

      Code:
      protected override void OnOrderUpdate(IOrder order) 
      { 
          if (order.OrderState == OrderState.Filled) 
          { 
                  SendMail("[email protected]", "[email protected]", "Orderfilled", "Position Stopped Out") 
           } 
      }
      How can you distinguish between an entry fill and an exit fill?

      Comment


        #4
        Hi RDPoS,

        Not explicitly, as no specific order type is designated as an exit order.
        You could check for position size with Market Position: http://www.ninjatrader.com/support/h...etposition.htm
        TimNinjaTrader Customer Service

        Comment


          #5
          Well I guess if I can somehow get it to recognize whether the strat has a position or is flat I can deduce which is which in the email. Is that possible to distinguish between 0 orders and 1 order (non-flat)?

          Comment


            #6
            Hi RDPoS,

            You would need to check for each OrderState explicilty: http://www.ninjatrader.com/support/h...tml?iorder.htm
            TimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            90 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            48 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            31 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            34 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            69 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X