Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to cancel limit order

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

    How to cancel limit order

    I have a strategy which uses:
    order1EntryLimitOrder = EnterShortLimit(5, true, Entry1Qty, Entry1Price, "Entry1");

    After a period of time, I do the following:

    if (order1EntryLimitOrder != null )
    {
    this.Orders.FindByOrderId(order1EntryLimitOrder.Or derId).Cancel();
    order1EntryLimitOrder = null;
    }

    Along the way I receive the following message:

    **NT** An Enter() method to submit an entry order at '8/22/2013 10:00:00 AM' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.

    When the this.Orders.FindByOrderId(order1EntryLimitOrder.Or derId).Cancel(); runs, it does not cancel the order. Go any ideas as to why?

    I also tried CancelOrder(order1EntryLimitOrder) and it didn't work either.

    Rich

    #2
    Hello richtobey,

    Thanks for your post.

    May I have a stripped down version of this strategy to run?

    There could be a few reasons this message is appearing and currently I do not have enough information to determine the cause.

    If you are not wanting to strip it down to just this issue, let me know and I'll have you send me the script privately.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Stripped down version of code

      I'm running this on a forex instrument connected via Interactive Brokers. Run this on 15 minute bars as your base bar for the strategy setup. I'm executing against the account Sim101. Attached is a bare bones strategy which should duplicate the issue. it has the relevant parts taken from my code.

      Thx Rich
      Attached Files
      Last edited by richtobey; 08-22-2013, 10:00 AM.

      Comment


        #4
        Hi richtobey,

        Thanks for the script. I am testing this out right now.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I noticed on another post some talk about the message I'm receiving. You might need to enter two limit orders at the same price to duplicate the issue. My code does this, but not the trimmed down version.

          Rich

          Comment


            #6
            Hi richtobey,

            This might be the case.

            The only error message i received was:
            **NT** Error on calling 'OnBarUpdate' method for strategy 'CancelLimitOrder/3831fcc1c0284e22aa735a9f504b0391': Object reference not set to an instance of an object.

            Did you test your sample code to ensure it causes this error?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Resolved

              I got it resolved. The problem was elsewhere. Thanks Rich

              Comment


                #8
                I'm back.

                Well. It's not resolved after all. I've struggled to create a set of code that produces the error. My main strategy is 30,000+ lines and it would be a mess to give you. But I have learned more. once I get the message "**NT** An Enter() method to submit an entry order at '8/22/2013 10:00:00 AM' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation", then all order functions cease to work. This includes cancel order as well as new entries.

                One thing I noticed is that if you run a strategy as "Unique entries" with a count of 1 and then submit 2 entries, you can't trust IOrder.OrderStatus. Then 2nd entry order will have a value of OrderStatus.Working when it's not "working." I suspect that this is not related though.

                What ever is causing that message is horking the order subsystem. Once horked, it ignores all new order actions. In my case I'm running 2 limit orders with keep alive set to true. After a period of time of less than 1 hour (I'm using 15m bars), something times out, gives that message and then I have the problem.

                One work around which I've played with is to have the order die at the end of a bar with keepalive set to false. then watch onorderupdate for the cancellation and resubmit it. This works but is messy having to submit 2 orders at the close of each bar. I shouldn't have to do this.

                So, can you ask around internally and see if anybody knows what might be generating that message. I've read the rules on it and that stuff doesn't apply. I've only got 2 short limit orders that are hanging out there. nothing in the other direction or anything related to stops etc. In my sample code that I built for you I can't get it to generate the message.

                I would be willing to show you this in action in a remote session if that helps?

                Comment


                  #9
                  Hello richtobey,

                  I would like to assist you and am willing to ask around here at the office, however, all of us here are going to need to look at your code.

                  If the strategy is really long, is it possible for you to remove things one at a time and test for the issue. If you could get this down to barebones that would be extremely helpful in determining the issue.

                  We can do that, or I could try and cause this error on my own and give you the code. Then you could look for any situations that are similar.
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by AttiM, 02-14-2024, 05:20 PM
                  12 responses
                  213 views
                  0 likes
                  Last Post DrakeiJosh  
                  Started by cre8able, 02-11-2023, 05:43 PM
                  3 responses
                  238 views
                  0 likes
                  Last Post rhubear
                  by rhubear
                   
                  Started by frslvr, 04-11-2024, 07:26 AM
                  8 responses
                  117 views
                  1 like
                  Last Post NinjaTrader_BrandonH  
                  Started by stafe, 04-15-2024, 08:34 PM
                  10 responses
                  47 views
                  0 likes
                  Last Post stafe
                  by stafe
                   
                  Started by rocketman7, Today, 09:41 AM
                  3 responses
                  12 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X