Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

atm orderid does not exist

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

    atm orderid does not exist

    I've looked at the sampleatmstrategy and researched articles on the forum and still can't get the atm to work the way I would like. It continues to enter multiple orders and displays various errors in the log. Please assist.

    The error:

    Strategy,GetAtmStrategyEntryOrderStatus() method error: orderId 'ab64978a025146628f29a6017b02d90b' does not exist,

    Strategy to follow in second post due to 10k character limitation.

    #2
    Hi mgin98,

    I don't think your second post came through. Would you mind attaching your strategy in a new post so I can take a look at it for you? Thank you.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      atmstrategyid error

      Thanks, see below.

      I'm wondering if I should include my entry conditions in the first line instead of several lines below.

      if (orderId.Length == 0 && atmStrategyId.Length == 0 )
      {
      atmStrategyId = GetAtmStrategyUniqueId();
      orderId = GetAtmStrategyUniqueId();
      if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Short)
      {
      if (CrossBelowblahblah)
      {
      AtmStrategyCreate(Action.Sell, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "basicmarv", atmStrategyId);
      DrawArrowDown("My down arrow" + CurrentBar, false, 0, 0, Color.Red);
      }
      }
      if (orderId.Length > 0)
      {
      string[] status = GetAtmStrategyEntryOrderStatus(orderId);
      if (status.GetLength(0) > 0)
      {
      if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
      {
      orderId = string.Empty;
      }
      }
      }
      elseif (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
      atmStrategyId = string.Empty;
      }

      Comment


        #4
        Hi mgin98,

        Let us take it from the top. You do have an ATM strategy already created titled "basicmarv" correct? If not you will need to first make this in a DOM or chart.

        The next thing to note is that you will want to have AtmStrategyCreate immediately after you declare atmStrategyId and orderId. The reason for this is because you are already assigning values to those variables, but no actual corresponding order exists with them until you submit an AtmStrategyCreate(). What is happening is you are going through the GetAtmStrategyEntryOrderStatus() on orderId before you submit any order. That results in the error you are receiving of "does not exist" because there is no order there.

        Hope that makes sense.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Yes, I have an atmtemplate created in the DOM called "basicmarv". (Since you mentioned it, I trade through MBT mini fx account. It requires 1000 lot for one micro lot when I test live but when I click the up/down arrows from 1 lot to get 1000 in DOM, there is no way to get an even 1000 lot. It goes from 1001, to 901 (down arrow) to 1101 (up arrow).

          Ok, I follow the rest of what you're saying. That brings me back to my original problem however. Will I still have to precondition the entry to prevent multiple entries in the same direction when new signals come in since I'm setting and resetting the IDs? That's what I attempted to do with:

          if
          (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Long) .....atmcreate

          I only want to enter a new order if no order in the same direction exist.

          I've made the changes you suggested and I'm running in sim to observe the behavior. BTW, I neglected to mention I'm running the same strategy in different directions on two separate subaccounts. Please advise if the IDs should be unique in this case (orderId1, 2, etc.). Thanks.

          Comment


            #6
            Please check out Tools->Option->Misc for some options on selecting pip size.

            You can validate your entries with that condition without problem because if atmStrategyId does not contain anything it will not return MarketPosition.Long so it will maintain true for you at the proper time.

            If you are running the same strategy, but two instances of it I believe you should be fine leaving it as is.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              atmstrategy

              Thanks NTJosh. Tools/Options/Misc already showed Pips. I tried another template and selected the instrument first, then entered quantity 1000, then selected Custom and that automatically entered the correct quantity in the greyed out Quantity field and worked just fine. I think before I selected all of the dropdowns, then entered quantity 1000, which then defaulted to 100 units. So I tried using the arrows and the quantity would never come up just right.

              The strategies are running fine now with only the occassional message that I reported before, and seems to only come up during position changes. It doesn't seem to affect how the strategy is running so I will watch it for a while for now. Also, I have not had a problem with multiple orders so we knocked out 3 birds with one stone. Thanks for the help.

              Comment


                #8
                If you are still receiving the "does not exist" message you may need to debug out the code to find where you end up accessing the orderId while there is no underlying order corresponding with it in the same manner we have done earlier. Good luck.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  atmstrategyid

                  Gotcha. The specific error now is:

                  "Strategy,GetAtmStrategyMarketPosition() method error: AtmStrategyId 'd37c629aa7f44a9785ee7df361c00dcb' does not exist,"


                  if (orderId.Length > 0)
                  {
                  string[] status = GetAtmStrategyEntryOrderStatus(orderId);

                  if (status.GetLength(0) > 0)
                  {
                  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 (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
                  {
                  orderId =
                  string.Empty;
                  }
                  }
                  }
                  elseif (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
                  atmStrategyId =
                  string.Empty;


                  This section is a direct paste from the sampleatmstrategy script (minus comments) and is the only place left in the strategy (bold text) where the marketposition method is being called now. Any ideas greatly appreciated.

                  Comment


                    #10
                    Same reason as earlier. You have to watch out for when your atmStrategyId does not contain an underlying order.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Josh View Post
                      Same reason as earlier. You have to watch out for when your atmStrategyId does not contain an underlying order.
                      Hi Josh - Is there some code he is missing in order to prevent that?

                      I have a very similar strategy written from the sample ATM.cs code in the reference section and I keep getting errors at the beginning of every new bar which also say,
                      GetAtmStrategyMarketPosition() method error: AtmStrategyId 'c9eab2ea04844088bcb9afd9f715d87b' does not exist
                      and
                      GetAtmStrategyEntryOrderStatus() method error: orderId 'fd088bb76675457abefe00c69f5505d8' does not exist

                      I've read every ATM strategy post and keep seeing the answer as "when your atmStrategyId does not contain an underlying order" this will happen but I can't see how to prevent this. Is there a reference to a working strategy anywhere with long and short entry conditions on the site? So when you don't have an underlying order you don't get those errors in the log? I have a similar problem and it stops my strategy from running.


                      Thanks.

                      Comment


                        #12
                        Below instead of,
                        "private string atmStrategyId = string.Empty;"

                        Should I have the same atmstrategyId as the DOM ATM template label which is "ES_2x_TrailStop_Short"?
                        So should the private string look like this
                        "private string ES_2x_TrailStop_Short = string.Empty;"

                        I have a long and short entry condition, do I need to have two else cancel statements after each condition also or just one?

                        else
                        AtmStrategyCancelEntryOrder(orderId);


                        Code:
                        private string    atmStrategyId        = string.Empty;
                                private string    orderId                = string.Empty;
                                #endregion
                        
                                /// <summary>
                                /// This method is used to configure the strategy and is called once before any strategy method is called.
                                /// </summary>
                                protected override void Initialize()
                                {
                                    CalculateOnBarClose = true;
                                }
                        
                                /// <summary>
                                /// Called on each bar update event (incoming tick)
                                /// </summary>
                                protected override void OnBarUpdate()
                                {
                                    // Make sure this strategy does not execute against historical data
                                    if (Historical)
                                        return;
                                    // Submits an entry stop order at the previous bar low/high +/- x ticks price to initiate an ATM Strategy if both order id and strategy id are in a reset state
                                    // **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'AtmStrategyTemplate' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK ****
                                    if (orderId.Length == 0 && atmStrategyId.Length == 0 
                                        && Close[2] > Open[2])
                                    {
                                        atmStrategyId = GetAtmStrategyUniqueId();
                                        orderId = GetAtmStrategyUniqueId();
                                        AtmStrategyCreate(Cbi.Action.Sell, OrderType.Stop, Low[0], 0, TimeInForce.Day, orderId, "ES_2x_TrailStop_Short", atmStrategyId);
                                    }
                        
                                    else
                                        AtmStrategyCancelEntryOrder(orderId);
                        
                                    // Submits an entry limit order at the current low price to initiate an ATM Strategy if both order id and strategy id are in a reset state
                                    // **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'AtmStrategyTemplate' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK ****
                                    if (orderId.Length == 0 && atmStrategyId.Length == 0 
                                        && Close[2] < Open[2])
                                    {
                                        atmStrategyId = GetAtmStrategyUniqueId();
                                        orderId = GetAtmStrategyUniqueId();
                                        AtmStrategyCreate(Cbi.Action.Buy, OrderType.Stop, High[0], 0, TimeInForce.Day, orderId, "ES_2x_TrailStop_Long", atmStrategyId);
                                    }
                        
                                    else
                                        AtmStrategyCancelEntryOrder(orderId);
                        
                                    // 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;

                        Comment


                          #13
                          MrTicks,

                          The variable name of atmStrategyId is unimportant. You can name it however you want.

                          If you have two separate entries you should use two separate string variables; one for each.

                          To avoid "does not exist" issues, you should only be trying to check the states of your orders and ATMs when they are actually active. If you try to check it when they are not active you will get that message. The moment the orders/ATM go inactive, you should reset the atmStrategyId and orderId back to empty.

                          What I suggest you do to debug your code is to add Print() statements along each step of the way and isolate out exactly which line is the one causing issues. Then you can address it at that point in time.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_Josh View Post
                            MrTicks,

                            The variable name of atmStrategyId is unimportant. You can name it however you want.

                            If you have two separate entries you should use two separate string variables; one for each.

                            To avoid "does not exist" issues, you should only be trying to check the states of your orders and ATMs when they are actually active. If you try to check it when they are not active you will get that message. The moment the orders/ATM go inactive, you should reset the atmStrategyId and orderId back to empty.

                            What I suggest you do to debug your code is to add Print() statements along each step of the way and isolate out exactly which line is the one causing issues. Then you can address it at that point in time.
                            Thanks Josh, will do.

                            Comment


                              #15
                              GetAtmStrategyEntryOrderStatus() method error: orderId does not exist

                              Originally posted by mgin98 View Post
                              I've looked at the sampleatmstrategy and researched articles on the forum and still can't get the atm to work the way I would like. It continues to enter multiple orders and displays various errors in the log. Please assist.

                              The error:

                              Strategy,GetAtmStrategyEntryOrderStatus() method error: orderId 'ab64978a025146628f29a6017b02d90b' does not exist,

                              Strategy to follow in second post due to 10k character limitation.
                              Has anyone found a way to modify the SampleATMStrategy so they don't get these errors in their logs?

                              I get the same errors as posted by mgin98 and a few others that have posted about this.

                              See another post with same query, http://www.ninjatrader.com/support/f...ead.php?t=7808 , their error is referenced in the 1st post.

                              I've seen replies referring people to the code guide and about debugging but no samples of code on how to prevent it.

                              Any help/code from anyone on how to prevent this error in the logs I would really appreciate it!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by inanazsocial, Today, 01:15 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post inanazsocial  
                              Started by trilliantrader, 04-18-2024, 08:16 AM
                              5 responses
                              22 views
                              0 likes
                              Last Post trilliantrader  
                              Started by Davidtowleii, Today, 12:15 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Davidtowleii  
                              Started by guillembm, Yesterday, 11:25 AM
                              2 responses
                              9 views
                              0 likes
                              Last Post guillembm  
                              Started by junkone, 04-21-2024, 07:17 AM
                              9 responses
                              70 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X