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

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 jpeep, 08-16-2020, 08:31 AM
                  17 responses
                  502 views
                  0 likes
                  Last Post notenufftime  
                  Started by ETFVoyageur, 05-07-2024, 07:05 PM
                  15 responses
                  124 views
                  0 likes
                  Last Post ETFVoyageur  
                  Started by esmall, Today, 07:14 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post esmall
                  by esmall
                   
                  Started by Option Whisperer, 05-09-2024, 07:58 PM
                  6 responses
                  26 views
                  0 likes
                  Last Post Option Whisperer  
                  Started by rayyyu12, Today, 05:38 PM
                  0 responses
                  13 views
                  0 likes
                  Last Post rayyyu12  
                  Working...
                  X