Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancel Order is not working as expected

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

    Cancel Order is not working as expected

    Hi,
    I am not able to test my strategy because cancel order is not working as expected.
    I have my indicator and strategy running on 2500(primary data series) volume chart and added one tick secondary data series for order execution by calling unmanaged order methods on one tick bars.

    Primary data series: 2500 volume
    Secondary data series: 1 tick for order execution.

    All the orders are place well ahead with limit price and based on market condition orders will be either modified or cancelled.

    As per my understanding orders will be executed at the close of the bar (1 tick in this case).
    But when I cancel the orders they are not getting cancelled at the end of one tick and they are getting cancelled at the end of 2500 bar.

    Order entry and order modification methods getting executed as expected (end of one tick bar) but the cancel order is getting executed at the end of 2500 volume bar.

    How do I execute the cancel order at the end of one tick bar?

    Example of Order execution calls:

    protected override void Initialize()
    {
    Add(PeriodType.Tick, 1); // secondary series for execution BarsInProgress == 1
    CalculateOnBarClose = true;
    Unmanaged = true;
    IgnoreOverFill=true;
    RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;
    }


    Ord=SubmitOrder(1,OrderAction.Sell ……………);
    ChangeOrder(Ord,……….);
    CancelOrder(Ord);


    OnExecution :
    checking entry orders fill by comparing entry order object, submitting both stop and PT orders (OCO) and setting entry order to null.
    Checking for PT order fill and setting PT order to null.
    Checking for Stop order fill and setting it to null.

    OnOrderUpdate:
    Checking for Cancelled orders and setting appropriate objects to null (entry, PT or Stop)
    Checking for Rejected orders and taking appropriate actions.


    It will be great if you can help me to get the orders cancelled on the same data series as orders submitted.

    Thanks,
    gsreddy.
    Last edited by gsreddy; 03-01-2015, 09:16 PM.

    #2
    Hello gsreddy,

    Thank you for your post.

    If the CancelOrder() is within the OnBarUpdate(), check for BarsInProgress == 1 and then submit the cancel.

    For example:
    Code:
    if(BarsInProgress == 1)
    {
    CancelOrder(...);
    }
    For information on running multiple series in your code please visit the following link: http://www.ninjatrader.com/support/h...nstruments.htm

    Please let me know if you have any questions.

    Comment


      #3
      hi Patrick,

      why do we need to check the BarsInProgress == 1 for cancel or submitting the orders?

      i have added 1 tick bars as secondary series and all the code is on 2500 vol bases.

      while submitting orders i am submitting on 1 tick series for execution by passing 1 to submit order.

      example:

      close of 2500 bar 1 => submit entry order Ord=SubmitOrder(1, .....)

      close of 2500 bar 2 => cancel the order CancelOrder(Ord);

      close of 2500 bar 3 => it is cancelling the order.

      but for in the 2500 bar 3, excepting to have > 100 i tick bars and this cancel should be executed on the close of first tick of the bar at the beginning of 2500 bar 3 instead of end of bar 2500 bar 3.

      is my understanding correct? ChangeOrder is working as expected but CancelOrder is not getting executed on 1 tick bar. but it is getting executed at the end of 2500 bar.

      i have also tried to submit both ChangeOrder and CancelOrder at the same time in the order and noticed ChangeOrder is getting executed on the close of 1 tick bar but CancelOrder is getting executed at the end of 2500 bar.

      thanks,
      gsreddy.

      Comment


        #4
        Hello gsreddy,

        Thank you for your response.

        Force it to CancelOrder() in BarsInProgress 1 and advise if the same behavior is seen.

        Comment


          #5
          do i need to do the below to force CancelOrder() in BarsInProgress 1

          if (BarsInProgress == 0) // 2500 vol
          {
          // check for cancel order condition and set cancel flag to true
          cancelflag=true;
          }
          else if (BarsInProgress == 1 && cancelflag ) // 1 tick
          {

          CancelOrder(ord);
          cancelflag=false;

          // i dont have nay thing else to do in this bars series excel cancel order
          }

          thanks

          Comment


            #6
            Originally posted by gsreddy View Post
            do i need to do the below to force CancelOrder() in BarsInProgress 1

            if (BarsInProgress == 0) // 2500 vol
            {
            // check for cancel order condition and set cancel flag to true
            cancelflag=true;
            }
            else if (BarsInProgress == 1 && cancelflag ) // 1 tick
            {

            CancelOrder(ord);
            cancelflag=false;

            // i dont have nay thing else to do in this bars series excel cancel order
            }


            thanks
            That would work.

            Comment


              #7
              possiable solution

              i had not same but i think similar issue.

              try this.... Instead of canceling the order. Place opposite side order.

              Comment


                #8
                thanks Patrick..

                i was able to solve this issue by calling cancel order on tick bar.

                thanks,

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Option Whisperer, Today, 09:55 AM
                0 responses
                3 views
                0 likes
                Last Post Option Whisperer  
                Started by geddyisodin, 04-25-2024, 05:20 AM
                8 responses
                58 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by halgo_boulder, 04-20-2024, 08:44 AM
                2 responses
                22 views
                0 likes
                Last Post halgo_boulder  
                Started by mishhh, 05-25-2010, 08:54 AM
                19 responses
                6,189 views
                0 likes
                Last Post rene69851  
                Started by gwenael, Today, 09:29 AM
                0 responses
                5 views
                0 likes
                Last Post gwenael
                by gwenael
                 
                Working...
                X