Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Email for order pending/fill/target/stop

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

    Email for order pending/fill/target/stop

    Anyway to send an Email for order pending/fill/target/stop/trailing stop move/etc?

    Most online brokers have that feature built in.

    Thanks in advance.

    #2
    SendMail() from OnOrderUpdate(). This can only be done from a strategy.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Josh View Post
      SendMail() from OnOrderUpdate(). This can only be done from a strategy.

      I've set up a autotrade strategy already. If i made a second strategy could both strats be used at the same time?

      Comment


        #4
        You can use both strategies, but they work completely independently of each other.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          You can use both strategies, but they work completely independently of each other.
          Got any code examples, I am not a coder by any means...

          Comment


            #6
            Unfortunately I do not have sample code. Please check out the Help Guide articles on those methods to get an idea.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              If using the sampleatmstrat could I add email to it as it has some status?

              // Check for a pending entry order
              if (orderId.Length > 0)
              {
              string[] status = GetAtmStrategyEntryOrderStatus(orderId);

              // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
              if (status.GetLength(0) > 0)
              {
              // Print out some information about the order to the output window
              Print("The entry order average fill price is: " + status[0]);
              Print("The entry order filled amount is: " + status[1]);
              Print("The entry order order state is: " + status[2]);

              // If the order state is terminal, reset the order id value
              if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
              orderId = string.Empty;

              Comment


                #8
                You can work with SendMail() to work status updates in - http://www.ninjatrader-support.com/H...SendMail1.html
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  I'm really not sure how to even start with this. Like this?

                  // Check for a pending entry order
                  if (orderId.Length > 0)
                  {
                  string[] status = GetAtmStrategyEntryOrderStatus(orderId);

                  // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
                  if (status.GetLength(0) > 0)
                  {
                  // Print out some information about the order to the output window
                  Print("The entry order average fill price is: " + status[0]);
                  Print("The entry order filled amount is: " + status[1]);
                  Print("The entry order order state is: " + status[2]);

                  // If the order state is terminal, reset the order id value
                  if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
                  orderId = string.Empty;
                  SendMail("[email protected]", "[email protected]", status[2], status[2]);

                  Comment


                    #10
                    Right. It seems like you are using the SendMail() method accurately.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Josh View Post
                      Right. It seems like you are using the SendMail() method accurately.
                      It does work and emails when initialized/working/filled.

                      Looking at NinjaTrader Order State Definitions I don't see anything for when targets are reached or when the order is stopped out.

                      Comment


                        #12
                        You would need to work with IOrder objects for this, here's a sample demonstrating this - http://www.ninjatrader-support2.com/...ead.php?t=7499
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by m3power222 View Post
                          I'm really not sure how to even start with this. Like this?

                          // Check for a pending entry order
                          if (orderId.Length > 0)
                          {
                          string[] status = GetAtmStrategyEntryOrderStatus(orderId);

                          // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
                          if (status.GetLength(0) > 0)
                          {
                          // Print out some information about the order to the output window
                          Print("The entry order average fill price is: " + status[0]);
                          Print("The entry order filled amount is: " + status[1]);
                          Print("The entry order order state is: " + status[2]);

                          // If the order state is terminal, reset the order id value
                          if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
                          orderId = string.Empty;
                          SendMail("[email protected]", "[email protected]", status[2], status[2]);
                          With this shouldn't I only get emails when it is either filled/cancelled/rejected?

                          I'm getting "working" emails at what appears every bar close but "working" isn't listed above.

                          Comment


                            #14
                            You don't have your if-statements in brackets.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Josh View Post
                              You don't have your if-statements in brackets.
                              That is how it is in the SampleATMStrategy before putting in the SendMail(). Is the SampleATMStrategy brackets wrong?

                              // Check for a pending entry order
                              if (orderId.Length > 0)
                              {
                              string[] status = GetAtmStrategyEntryOrderStatus(orderId);

                              // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
                              if (status.GetLength(0) > 0)
                              {
                              // Print out some information about the order to the output window
                              Print("The entry order average fill price is: " + status[0]);
                              Print("The entry order filled amount is: " + status[1]);
                              Print("The entry order order state is: " + status[2]);

                              // If the order state is terminal, reset the order id value
                              if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
                              orderId = string.Empty;
                              }
                              } // If the strategy has terminated reset the strategy id
                              else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
                              atmStrategyId = string.Empty;


                              if (atmStrategyId.Length > 0)
                              {
                              // You can change the stop price
                              if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
                              AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "STOP1", atmStrategyId);

                              // Print some information about the strategy to the output window
                              Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
                              Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
                              Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId)) ;
                              Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyId)) ;
                              }
                              }

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by funk10101, Today, 12:02 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post funk10101  
                              Started by gravdigaz6, Yesterday, 11:40 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by MarianApalaghiei, Yesterday, 10:49 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by XXtrader, Yesterday, 11:30 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post XXtrader  
                              Started by love2code2trade, 04-17-2024, 01:45 PM
                              4 responses
                              28 views
                              0 likes
                              Last Post love2code2trade  
                              Working...
                              X