Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Canceling an order

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

    Canceling an order

    I place the following order :

    tmStrategyCreate(Action.Buy,OrderType.StopLimit,Op en[0]+ 1* TickSize, Open[0] + 1 * TickSize, TimeInForce.Day, OrderId,"BahramBreakout", atmOrderId)

    The order is place and i can see it.

    When I try to cancel the order with the following:



    lastRedOrderId = OrderId;
    atmlastRedOrderId = atmOrderId;
    AtmStrategyCancelEntryOrder("lastRedOrderId");
    AtmStrategyCancelEntryOrder("atmlastRedOrderId");

    But, the order never gets canceled.

    ANy idea's?

    #2
    You need to ensure you are using the correct orderId value. Use GetAtmStrategyEntryOrderStatus(orderId) to help you figure out if you have the proper orderId. Please see how to do this with SampleAtmStrategy.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Am i Suppose to use the OrderID or the ATMOrderID to cancel the pending order?


      Thanks!

      Comment


        #4
        The orderId.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I have tried and tried to cancel an Order that has a status of Accepted.

          i have checked and double checked to make sure its the same OrderID that was accepted. But, i keep getting an error.
          I know its the right order ID since i see the order on the dom and i can see the trace msgs in the output window.




          if ( Close[0] > Open[0] )
          {
          Print (" *********** Processing Green Bar **************");
          if ( !AtmStrategyCreate(Action.Sell,OrderType.StopLimit ,Open[0]- 1* TickSize, Open[0] - 1 * TickSize, TimeInForce.Day, OrderId,"BahramBreakout", atmOrderId) )
          {
          Print( "Order Not Accepted Green ===[" + OrderId + "], [" +atmOrderId + "]");
          }
          else
          {
          Print (" Order accepted Processing");
          if (lastGreenOrderId != null)
          {
          Print ("lastgreenOrderID.lenght [" + lastGreenOrderId.Length.ToString() + "]");
          string[] status = GetAtmStrategyEntryOrderStatus(lastGreenOrderId);
          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")
          {
          lastGreenOrderId = null;
          Print( "Setting lastgreenOrderID to blank");
          }
          else
          {
          if ( lastGreenOrderId != null )
          {
          Print( " In Cancel Green for *** [" + lastGreenOrderId + "], [" +atmlastGreenOrderId + "]");

          if ( !AtmStrategyCancelEntryOrder("lastGreenOrderId") )
          Print ("Order Not canceled Green");
          else
          Print ("Order Canceled Green");
          }
          }
          }
          }
          lastGreenOrderId = OrderId;
          atmlastGreenOrderId = atmOrderId;
          Print( "Processed Order [" + OrderId + "], [" +atmOrderId + "]");
          lastGreenLow = High[0];
          lastGreenOpen = Open[0];
          DrawHorizontalLine("BDOpenLine" + Time[0].ToString() + "", Open[0] - 1* TickSize, Color.Purple);
          if ( lastGreenDrawObjectName != null )
          {
          RemoveDrawObject( lastGreenDrawObjectName);
          }
          lastGreenDrawObjectName = "BDOpenLine" + Time[0].ToString() + "";

          Print( "************** END PRocessing of Green ***************");








          here is my TRACE from the Ouput WIndow:



          *********** Processing Green Bar **************
          Order accepted Processing
          lastgreenOrderID.lenght [32]
          The entry order average fill price is: [0]
          The entry order filled amount is: [0]
          The entry order order state is: [Accepted]
          In Cancel Green [f09baaa1173f4bf2aea22a01ae6beb6f], [24f991a426e4423d92bb224c5b4e7088]
          Order Not canceled Green
          Processed Order [90bcbe61308b4aeeb84135620de6a4a7], [a1a012b4a2b0434584f552b1a62bb3db]
          ************** END PRocessing of Green ***************

          Comment


            #6
            What is the error you are getting?
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              I did not know, there was an error code returned. In the docs it only says, the function returns True or False.

              How can i get an error code?

              Comment


                #8
                Ok. I am an idiot.

                I think i figured it out.

                Comment


                  #9
                  Great. Glad you got it resolved.
                  Josh P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  623 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  359 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  105 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  562 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  567 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X