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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            117 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            166 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            85 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            130 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            88 views
            0 likes
            Last Post PaulMohn  
            Working...
            X