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 rocketman7, Today, 02:12 AM
            5 responses
            22 views
            0 likes
            Last Post rocketman7  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            7 responses
            28 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by samish18, 04-17-2024, 08:57 AM
            17 responses
            66 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by briansaul, Today, 05:31 AM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by PaulMohn, Today, 03:49 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X