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

entry order id

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

    entry order id

    I'm using GetAtmStrategyEntryOrderStatus and I get the error "GetAtmStrategyEntryOrderStatus() method error: orderID 'd15es85 etc' does not exist.

    This is after I do
    if (OrderId.Length > 0) // Check for a pending entry order

    So I guess I need to understand how the entry order id changes through the order and execution process.

    Before I do AtmStrategyCreate, I do OrderId = GetAtmStrategyUniqueId() .

    Apparently this value changes somehow, somewhere that I don't know about.

    #2
    Kentoes, do you also reset the id's to empty if the order is filled, cancelled or rejected so reaches a terminal state?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Kentoes, do you also reset the id's to empty if the order is filled, cancelled or rejected so reaches a terminal state?
      No. How and when should this be done?

      If the id doesn't exist, how can GetAtmStrategyEntryOrderStatus be used to check to see if the order is filled, canceled or rejected?

      Comment


        #4
        Please have a look at the SampleAtmStrategy we install per default - the needed sample code for the resets for order and stratey Id's would be shown there, the Id submitted to GetAtmEntryOrderStatus will need to exist and be valid.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Followed the sample code and still getting the error "GetAtmStrategyEntryOrderStatus() method error: orderID 'd15es85 etc' does not exist.

          First trade executes. Nothing after that.

          Code:
                  protected override void OnBarUpdate()
                  {
                      if (Historical)
                          return;
                      
                      
                      LongStopTrigger = MAX(High, Lookback)[0] + 1*TickSize;
                      ShortStopTrigger = MIN(Low, Lookback)[0] - 1*TickSize;
                      if (LongStopTrigger-Close[0]>Close[0]-ShortStopTrigger && OrderId.Length == 0 && AtmStrategyId.Length == 0 ) //go short
                      {
                                     
                          AtmStrategyId = GetAtmStrategyUniqueId(); 
                          OrderId = GetAtmStrategyUniqueId();
                          AtmStrategyCreate(Action.Sell, OrderType.Stop, 0,ShortStopTrigger, TimeInForce.Day, AtmStrategyId, "Standard", OrderId);
                          LastStop = ShortStopTrigger;
                      }
                      else if (LongStopTrigger-Close[0]<Close[0]-ShortStopTrigger && OrderId.Length == 0 && AtmStrategyId.Length == 0 )// go long
                      {
                              AtmStrategyId = GetAtmStrategyUniqueId(); 
                              OrderId = GetAtmStrategyUniqueId();
                              AtmStrategyCreate(Action.Buy, OrderType.Stop, 0,LongStopTrigger, TimeInForce.Day, AtmStrategyId, "Standard", OrderId);
                              LastStop = LongStopTrigger;
                      }
                                  // 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)
                          {
                              // 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;    
                  }

          Comment


            #6
            The code looks ok to me at a glance, can you please try running the default SampleAtmStrategy with a fresh setup template called AtmStrategyTemplate? Would this work without the error?

            Are there any other strategy related errors (related to order price you submit the stop at etc) in the logs before the strategy template for the exits would be called?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              SampleAtmStrategy runs fine with no errors.

              No other errors showing. After the first trade, just the orderID does not exist repeated over and over referencing the same ID number.

              Comment


                #8
                Have you tried your strategy also with a freshly created ATM template in case the one you were trying to use was corrupted for example?

                Can you please send me your full code used and trace / logs from today via Help > Mail to Support to my Attn so I can look into?

                Thanks
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Thanks. New ATM template gives same results. Files sent.

                  Comment


                    #10
                    Kentoes,

                    I didn't see anything come into our system in terms of your files. Did you receive a ticket # for when you sent in the files?
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Got an email from Kyle Nottingham requesting a link to this post. Sent.

                      Comment


                        #12
                        Kentoes,

                        You will want to add some Print() throughout your code and isolate out which line exactly is running into the OrderID messages. I suggest putting Print() lines in front of anywhere you have OrderID used so you can see where your code is reaching each time the message gets printed.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          You will want to add some Print() throughout your code and isolate out which line exactly is running into the OrderID messages. I suggest putting Print() lines in front of anywhere you have OrderID used so you can see where your code is reaching each time the message gets printed.
                          Done that. The answer is that the line of code is
                          Code:
                          string[] status = GetAtmStrategyEntryOrderStatus(OrderId);
                          Which still doesn't explain what's going on, in fact this is telling me the same thing as my first post in this thread. Again, how does the order id change, such that when it is attempted to be accessed, that particular value doesn't exist?

                          Comment


                            #14
                            Hello Kentoes,

                            The issue here seems to be the order of parameters specified in your AtmStrategyCreate method. Below you have in two different places:

                            AtmStrategyCreate(Action.Sell, OrderType.Stop, 0,ShortStopTrigger, TimeInForce.Day, AtmStrategyId, "Standard", OrderId);

                            AtmStrategyCreate(Action.Buy, OrderType.Stop, 0,LongStopTrigger, TimeInForce.Day, AtmStrategyId, "Standard", OrderId);

                            Swap the red text with blue text and it should now work properly for you. Sell Example:

                            AtmStrategyCreate(Action.Sell, OrderType.Stop, 0,ShortStopTrigger, TimeInForce.Day, OrderId, "Standard", AtmStrategyId);


                            Ryan M.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by martin70, 03-24-2023, 04:58 AM
                            14 responses
                            105 views
                            0 likes
                            Last Post martin70  
                            Started by TraderBCL, Today, 04:38 AM
                            0 responses
                            2 views
                            0 likes
                            Last Post TraderBCL  
                            Started by Radano, 06-10-2021, 01:40 AM
                            19 responses
                            606 views
                            0 likes
                            Last Post Radano
                            by Radano
                             
                            Started by KenneGaray, Today, 03:48 AM
                            0 responses
                            4 views
                            0 likes
                            Last Post KenneGaray  
                            Started by thanajo, 05-04-2021, 02:11 AM
                            4 responses
                            470 views
                            0 likes
                            Last Post tradingnasdaqprueba  
                            Working...
                            X