Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CancelOrder question

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

    CancelOrder question

    Hi,
    In a strategy, what, other than a call to CancelOrder can cause an order to be cancelled in the middle of the day?
    I have a single line of code for cancelling an order in my strat.
    I entered a trade along with a stop and target. Eventually, (read about 10 minutes) the stop and target orders got cancelled without my code for CancelOrder ever being hit (I had a breakpoint and a print statement on it). This left me with a naked trade that was obviously not what I wanted. So, what can cause this? It was not and end of day situation, it was not a rollover, it was not some error (nothing in the log.). Any ideas?
    Thanks ... Ed

    #2
    Originally posted by edstaffin View Post
    Hi,
    In a strategy, what, other than a call to CancelOrder can cause an order to be cancelled in the middle of the day?
    I have a single line of code for cancelling an order in my strat.
    I entered a trade along with a stop and target. Eventually, (read about 10 minutes) the stop and target orders got cancelled without my code for CancelOrder ever being hit (I had a breakpoint and a print statement on it). This left me with a naked trade that was obviously not what I wanted. So, what can cause this? It was not and end of day situation, it was not a rollover, it was not some error (nothing in the log.). Any ideas?
    Thanks ... Ed
    Were your orders marked "liveUntilCancelled"?

    Comment


      #3
      Ok, I figured out what's happening. I could sure use some help in fixing it.
      Here's the problem. I go to make a trade. In doing so, amongst other things, I do the following:
      1. Call SetStopLoss
      2. Call SetProfitTarget
      3. EnterLongLimint/EnterShortLimit

      Off we go. Prior to my getting filled (in separate call to OnBarUpdate), I may decide I need to change the limit price. So I make a call to EnterLongLimit or EnterShortLimit using the original order's Name as the signal. This is the documented way to do this. And yes, I have the IsLiveUntilCancel bool set to true.

      After making this update, my original stop and target orders are cancelled. NT seems to be doing this behind the scenes in the managed trade apparatus. The problem is, the stop and targets are not getting reset thus leaving me naked. Is this a bug? Or, do I need to reset the stop and target after the originals get cancelled? If I need to reset them. Where and how? Do I reset them before I reset the EnterLongLimit/EnterShortLimit. Do I catch the OnOrderUpdate, check the OrderState for cancelled and reenter it there? What's the "right" way to handle this?
      Thanks ... Ed

      Comment


        #4
        Originally posted by edstaffin View Post
        ...
        After making this update, my original stop and target orders are cancelled. NT seems to be doing this behind the scenes in the managed trade apparatus. The problem is, the stop and targets are not getting reset thus leaving me naked. Is this a bug? Or, do I need to reset the stop and target after the originals get cancelled? If I need to reset them. Where and how? Do I reset them before I reset the EnterLongLimit/EnterShortLimit. Do I catch the OnOrderUpdate, check the OrderState for cancelled and reenter it there? What's the "right" way to handle this?
        Thanks ... Ed
        That sounds incorrect.
        • Are you sure that you are not doing anything other than changing the entry order? The Set...() methods supposedly key off the entry to place the exit orders.
        • How are you using the Set...() methods? Are you specifying by price, ticks or percentage?

        In any case, I happen to know a bit of what you are coding. You probably should let go of the Set...() methods and use the Exit...() methods instead. You have much better control, even in the Managed trade system.

        Call me up. Let us see if I cannot help straighten this out.

        Comment


          #5
          I'm fried for today and have to deal with a Hurricane today and tomorrow. Can you PM me your phone number? I seem to have misplaced it.
          Thanks ... Ed

          Comment


            #6
            So what you are saying is to cancel the order outright and reenter the whole thing as if new?
            Thanks ... Ed

            Comment


              #7
              Originally posted by edstaffin View Post
              So what you are saying is to cancel the order outright and reenter the whole thing as if new?
              Thanks ... Ed
              Not really. I am saying that the Set...() methods are sort of automatic exit processing, and the orders that they place only happen after an entry is actually filled, not when the order is placed, so, in the normal course of things, altering the entry pre-entry should have no effect.

              On the other hand, Exit...() orders must be explicitly placed, so any spurious effects of semi-automation are moot.

              Comment


                #8
                As it turns out, it was a bug that was fixed in rc2.
                specifically:
                Fixed
                10342
                NinjaScript, Orders
                Stops and targets automatically cancelled incorrectly on multi-series strategy

                I guess the guys in the forum didn't know about it.
                Thanks ... Ed

                Comment


                  #9
                  Hello,
                  Thanks for everyone's post.
                  I can confirm this was bug in RC1 and was resolved in RC2.
                  BrandonNinjaTrader Customer Service

                  Comment


                    #10
                    I sure did waste a lot of time on this. I wish I had known about it earlier.

                    Comment


                      #11
                      Originally posted by edstaffin View Post
                      I sure did waste a lot of time on this. I wish I had known about it earlier.
                      Well yes, and I failed to realize that you were talking about NT8. or I probably would not have interjected.

                      But, as a software engineer yourself, I am sure you remember that such things are in the nature of beta software.

                      Comment


                        #12
                        Absolutley!! However, I can honestly say I have never been a part of, or even heard of, a 2+ year beta. Hell, it didn't take that long to write a version of Windows (I know, I was there). Oh well.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by GussJ, 03-04-2020, 03:11 PM
                        16 responses
                        3,281 views
                        0 likes
                        Last Post Leafcutter  
                        Started by WHICKED, Today, 12:45 PM
                        2 responses
                        19 views
                        0 likes
                        Last Post WHICKED
                        by WHICKED
                         
                        Started by Tim-c, Today, 02:10 PM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by Taddypole, Today, 02:47 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post Taddypole  
                        Started by chbruno, 04-24-2024, 04:10 PM
                        4 responses
                        53 views
                        0 likes
                        Last Post chbruno
                        by chbruno
                         
                        Working...
                        X