Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancel unfilled Auto order not working ..need help

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

    #16
    Originally posted by pdawg View Post
    Ray,

    Thanks for that. I will test it out let you know what I find.
    Hi pdawg - Did you find a solution to the orderID does not exist entry in your logs? If so, could you share the code that solved the issue?


    Thanks!

    Comment


      #17
      Originally posted by MrTicks View Post
      Hi pdawg - Did you find a solution to the orderID does not exist entry in your logs? If so, could you share the code that solved the issue?
      I'd be interested in this as well as I'm having the exact same problem cancelling an order. In fact, my strategy works just like the one from the OP, ie if the order hasn't been filled after the bar that generated it has closed, then I'd like to cancel it. I've tried to import the code snippet created by NinjaTrader_Ray named "Test" (thanks Ray), but I'm getting an error message when importing it, so this didn't help much I'm afraid.

      It would be great to have a generic example of a strategy that cancels an order if certain criteria are met (for example if the order hasn't been filled after one bar) in the Ninja Help section as there's only very little information available about this command and it seems that I'm not the only one struggling with it.

      It's not about debugging the code or adding "print" commands, it's about learning from an actual example.

      Thanks.
      Last edited by laocoon; 04-09-2013, 12:49 AM.

      Comment


        #18
        Hello laocoon,

        I have changed the sample code so that it is compatible inside of NinjaTrader 7 so that you can have an example code of this.

        To Import
        1. Download the attached file to your desktop
        2. From the Control Center window select the menu File > Utilities > Import NinjaScript
        3. Select the downloaded file

        Note that on any files that say "File already exists on your PC" that start with an "@" symbol are the ones that came preloaded inside of NinjaTrader so you would say "No" so that you do not override those files.
        Attached Files
        JCNinjaTrader Customer Service

        Comment


          #19
          Hello JC

          Thanks a lot for that, I'll have a close look at it.

          Have a great day.

          Comment


            #20
            I've tested the sample code and it obviously works well, but I'm really at a loss when it comes to adding a very simple condition to the "Cancel" command.

            This is Ray's / JC's original code:

            if (!orderPlaced && my conditions here)
            {
            orderId = GetAtmStrategyUniqueId();
            AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.StopLimit,High[0]+1*TickSize,High[0]+1*TickSize,TimeInForce.Day, orderId, "test", "testStrategyIdValue");
            orderPlaced = true;
            }
            else
            AtmStrategyCancelEntryOrder(orderId);
            }


            Now, if I add the condition on which the order shall be cancelled, ie that the bar following the signal doesn't make a higher high, I get the following error message: Missing orderId parameter.

            All I modified was this:

            else if (High[0] <= High[1])
            {
            AtmStrategyCancelEntryOrder(orderId);
            }

            Any pointers as to what I'm missing here would be greatly appreciated.
            Last edited by laocoon; 04-10-2013, 06:14 AM.

            Comment


              #21
              Hello laocoon,

              I am not having any issues placing the "else if (High[0] <= High[1]) " and canceling the order. You may want to add some checks to make sure you have a proper "orderId" before trying to call a cancel like in the "SampleAtmStrategy" strategy that comes preloaded inside of NinjaTrader.
              JCNinjaTrader Customer Service

              Comment


                #22
                Thanks JC, I managed to make it work.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                666 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                377 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                110 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                575 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                580 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X