Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

1 ATM order at a time, please

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

    #76
    Hi Austin,

    I appreciate your trying but I'm afraid I have zero change to report. Happy to try anything else as I have to believe there is a way to cancel a limit order intrabar.

    Thanks,
    Dave

    Comment


      #77
      It turns out that there was nothing wrong with my entry or cancellation code. What's been causing the cancellations was the addition of other charts, using Add() and BarsInProgess = 0, 1, 2, etc. Basically, even though my orders came off BarsInProgess(0), they were being cancelled but the other two. Is there any way to prevent that from happening? If so, I should be home free.

      Thanks,
      Dave

      UPDATE: Figured it out. Used entryOrder1 and entryOrder2 for BarInProgress == 0 and BarsInProgress == 1, respectively, etc. Everything now works exactly as I wanted. You guys hiring?
      Last edited by dsraider; 02-07-2010, 04:19 PM.

      Comment


        #78
        Hello dsraider,

        Great to hear you solved the issue.

        Please see the link below regarding employment opportunities at NinjaTrader.

        Comment


          #79
          I was just kidding, Jason, but thanks for the link. I'm not sure my 2.5 weeks of coding would qualify me for anything...

          Comment


            #80
            Hey guys,

            My CancelOrder() code is giving me problems. If I have an entry limit order at 1000 and it doesn't fill, I want the order to cancel the instant price hits 1001 or 4 ticks away. With CalculateOnBarClose set to false and my entry order set to Close[0] of the signal bar, I've tried if(Close[0] > Close[1] + 3 * TickSize) and if(GetCurrentBid > Close[1] + 3 * TickSize). They SOMETIMES work but if a bar should pass, Close[0] and Close[1] now have new definitions. Is it possible to somehow have the strat recognize the entry order price and then cancel if Close[0] > entryPrice + 3 * TickSize where Close[0] represents current price?

            Thanks,
            Dave

            Comment


              #81
              Hi Dave, thanks again for stopping by our booth at the Traders Expo in New York - you can access the limitPrice property of your IOrder for this task - http://www.ninjatrader-support.com/H...V6/IOrder.html

              Comment


                #82
                Awesome, Bertrand.

                It was great meeting you too. Please pass that on to Josh as well (I don't want him thinking I'm playing favorites).

                Thanks!
                Dave

                Comment


                  #83
                  You're welcome, will for sure mention it to Josh!

                  Comment


                    #84
                    Okay, I need a hint. How does this look?:

                    Variables
                    {
                    Private IOrder limitPrice = null;
                    }

                    ...

                    //Cancel order if price moves two ticks away without filling
                    else if (entryOrder1 != null && Close[0] >= limitPrice + 4 * TickSize)
                    {
                    CancelOrder(entryOrder1);
                    }

                    Should I be accessing limitPrice more directly?

                    Thanks,
                    Dave

                    Comment


                      #85
                      You cannot go limitPrice + 4 * TickSize. limitPrice is an IOrder object and not a double.

                      If you want to access the limit price of the IOrder object you want to do limitPrice.LimitPrice. You can only check any limitPrice properties after you ensure it is not null though.

                      if (entryOrder1 != null && limitPrice != null && Close[0] >= limitPrice.LimitPrice + 4 * TickSize)
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #86
                        Josh,

                        You rock! Thanks. This SHOULD compete this thing. I'm not sure of the protocol for posting sample strats. Should I repost here when complete for you guys to okay before it gets posted?

                        Thanks,
                        Dave

                        Comment


                          #87
                          Dave,

                          Glad you got it to work. There is no need to repost it here. If you want to share it you can go on ahead and share it in the File Sharing section for strategies.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #88
                            I spoke too soon:

                            if (Position.MarketPosition == MarketPosition.Flat && BarsInProgress == 0)
                            {
                            // Entry Condition: Enters long limit order when 20 EMA crosses above 50 EMA and a short limit order for the opposite.

                            if (entryOrder1 == null && entryOrder2 == null && FirstTickOfBar && CrossAbove(EMA(20), EMA(50), 1))
                            {
                            entryOrder1 = EnterLongLimit(0, true, DefaultQuantity, Open[0], "Long 1a");
                            entryOrder2 = EnterLongLimit(0, true, DefaultQuantity, Open[0], "Long 1b");

                            }
                            //Cancel order if price moves four ticks away without filling
                            else if (entryOrder1 != null && limitPrice != null && Close[0] >= limitPrice.LimitPrice + 4 * TickSize && entryOrder2 != null && limitPrice != null && Close[0] >= limitPrice.LimitPrice + 4 * TickSize)
                            {
                            CancelOrder(entryOrder1);
                            CancelOrder(entryOrder2);
                            }

                            Doesn't work. I have a private IOrder = null; snippet up top. Did I miss a step?

                            Thanks.

                            Comment


                              #89
                              Please be more descriptive as to what part doesn't work? Your code has no where with limit price being set.
                              Josh P.NinjaTrader Customer Service

                              Comment


                                #90
                                Sorry about that. I have the following under variables:

                                private IOrder limitPrice = null;

                                Everything works but the CancelOrder code.

                                Thanks.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                77 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                45 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                27 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                32 views
                                0 likes
                                Last Post TheRealMorford  
                                Started by Mindset, 02-28-2026, 06:16 AM
                                0 responses
                                63 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Working...
                                X