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

    #31
    Originally posted by NinjaTrader_Josh View Post
    Please try with all caps. "TARGET1"
    Tried that and still does not work.

    Looked through the log and see this:
    Category Strategy in yellow 'TARGET1' does not exist

    Category Order Name='Target1' New State=Working............

    Comment


      #32
      Does your ATM strategy actually have a target order then?
      Josh P.NinjaTrader Customer Service

      Comment


        #33
        Originally posted by NinjaTrader_Josh View Post
        Does your ATM strategy actually have a target order then?
        Here is what it looks like.
        Attached Files

        Comment


          #34
          Are you sure you are passing in the correct atmStrategyId for the ATM that is actually active?
          Josh P.NinjaTrader Customer Service

          Comment


            #35
            Originally posted by NinjaTrader_Josh View Post
            Are you sure you are passing in the correct atmStrategyId for the ATM that is actually active?

            I have this:

            private string atmStrategyId = string.Empty;

            Comment


              #36
              You should be storing the ID of your atm strategy into that string. Please ensure the string is not empty when you try to do GetAtmStrategy...().
              Josh P.NinjaTrader Customer Service

              Comment


                #37
                Originally posted by NinjaTrader_Josh View Post
                You should be storing the ID of your atm strategy into that string. Please ensure the string is not empty when you try to do GetAtmStrategy...().

                I have no idea, do you have an example?

                Comment


                  #38
                  Please take a look at the SampleAtmStrategy.

                  if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
                  {
                  atmStrategyId = GetAtmStrategyUniqueId();
                  orderId = GetAtmStrategyUniqueId();
                  AtmStrategyCreate(Cbi.Action.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
                  }
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #39
                    Originally posted by NinjaTrader_Josh View Post
                    Please take a look at the SampleAtmStrategy.

                    if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
                    {
                    atmStrategyId = GetAtmStrategyUniqueId();
                    orderId = GetAtmStrategyUniqueId();
                    AtmStrategyCreate(Cbi.Action.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
                    }

                    Yes I have all that stuff as my strategy is modified version of the SampleAtmStrat.

                    Does atmStrategyId = GetAtmStrategyUniqueId(); need to be put somewhere else again.

                    Comment


                      #40
                      Please post complete code of what you have. Thank you.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #41
                        Originally posted by NinjaTrader_Josh View Post
                        Please post complete code of what you have. Thank you.

                        Here you go:



                        // 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]", "Order", status[2]);
                        }
                        }
                        } // 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)
                        {
                        // 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)) ;
                        }

                        // Check for a pending entry order
                        if (atmStrategyId.Length > 0)
                        {
                        string[,] orders = GetAtmStrategyStopTargetOrderStatus("Target1", atmStrategyId);

                        // Check length to ensure that returned array holds order information
                        if (orders.Length > 0)
                        {
                        for (int i = 0; i < orders.GetLength(0) - 1; i++)
                        {
                        Print("Average fill price is " + orders[i, 0].ToString());
                        Print("Filled amount is " + orders[i, 1].ToString());
                        Print("Current state is " + orders[i, 2].ToString());
                        SendMail("[email protected]", "[email protected]", "Target", orders[i, 2].ToString());
                        }
                        }
                        }

                        }
                        Last edited by m3power222; 06-26-2009, 12:05 PM. Reason: Edit

                        Comment


                          #42
                          Please comment out this line: atmStrategyId = string.Empty;

                          And then try again so as to ensure it is not empty. Please also use different variables for your two different orders. You should have a completely separate set of ID tracking variables for your longs and shorts.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #43
                            Originally posted by NinjaTrader_Josh View Post
                            Please comment out this line: atmStrategyId = string.Empty;

                            And then try again so as to ensure it is not empty. Please also use different variables for your two different orders. You should have a completely separate set of ID tracking variables for your longs and shorts.

                            I've commented out the variable.

                            To see if it is not empty do I need to Print()?

                            The single ID tracking vars are working they way they are...???

                            Comment


                              #44
                              Right. You could do a print. The single ID tracking is good for tracking one at a time. I am not sure if your strategy would start crossing over each other or not. Easiest just to keep it clean and simple and use two sets.
                              Josh P.NinjaTrader Customer Service

                              Comment


                                #45
                                Originally posted by NinjaTrader_Josh View Post
                                Right. You could do a print. The single ID tracking is good for tracking one at a time. I am not sure if your strategy would start crossing over each other or not. Easiest just to keep it clean and simple and use two sets.

                                When I compile I get a bunch of atmstrategyId's do not exist...

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by cls71, Today, 04:45 AM
                                0 responses
                                1 view
                                0 likes
                                Last Post cls71
                                by cls71
                                 
                                Started by mjairg, 07-20-2023, 11:57 PM
                                3 responses
                                213 views
                                1 like
                                Last Post PaulMohn  
                                Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                                4 responses
                                544 views
                                0 likes
                                Last Post PaulMohn  
                                Started by GLFX005, Today, 03:23 AM
                                0 responses
                                3 views
                                0 likes
                                Last Post GLFX005
                                by GLFX005
                                 
                                Started by XXtrader, Yesterday, 11:30 PM
                                2 responses
                                12 views
                                0 likes
                                Last Post XXtrader  
                                Working...
                                X