Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Internal Order Handling Errors

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

    Internal Order Handling Errors

    When using limit orders for entries how can I get Ninja to reverse when a condition is true. When I program the same strategy using market orders the reverse is just fine, but when I change to limit orders my entries are "ignored" because of "Internal Order Handling Errors". I am using an offset of 1 tick from the close of the current bar so not going through the price is not the issue. It's strickly NinjaTrader's ignoring the trade. What is the work around for this problem and why does NinjaTrader feel the need to ignore my trade anyway?

    The purpose for the limit order is that using market orders develops at least 2 ticks of slippage where as using limit orders with 1 tick offset from the close is a built in 1 tick slippage, but NinjaTrader, for some reason I am not clear on, won't allow limit order reverses.

    #2
    Hi kenb2004,

    There's nothing inherent in limit orders that prevents them from being used to reverse. You are running into internal order handling rules due to a conflict with another working order. Maybe you have also SetProfitTarget()?

    Internal order rules are detailed on this page.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I am not using SetProfitTarget() but I do have ExitLongLimt() and ExitLongStop() n ticks from entry(Position.AvgPrice). Is this what it inhibiting the reverse and why? What is the purpose of ignoring my trades?

      Comment


        #4
        With a working ExitLongLimit(), you're running into the rule below. NinjaTrader is a real-time live trading platform and thus we need to ensure that we prevent situations in real-time where you may have multiple orders working accomplishing the same task.

        You can cancel the working ExitLongLimit() prior to submitting the short limit reversal. If the internal handling rules prevent you from accomplishing your coding goals, you can use the unmanaged approach, which has no rules and no NT position management.


        Methods that generate orders to enter a position will be ignored if:
        A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
        • A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction
        • The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
        • The entry signal name is not unique
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Ryan
          You say "There's nothing inherent in limit orders that prevents them from being used to reverse", but when I use a market order in the very same instance both the ExitLongLimit and the ExitLongStop are cancelled automatically. But when I use Limit entry to reverse the order is ignored and the Exits are NOT cancelled. Why are the Exits not cancelled when using limit orders? How can the Exits be cancelled in order to reverse with a limit order?

          Comment


            #6
            The rules do not apply to market orders. Yes, if you're in a position and have working exit orders, an Enter method will automatically cancel these exit orders. Your EnterLimit order is never sent though - it's ignored.

            You need to manually cancel your working exit orders if you want your EnterLimit order to be submitted. This sample can help with using CancelOrder()
            When using NinjaTrader's Enter() and Exit() methods, the default behavior is to automatically expire them at the end of a bar unless they are resubmitted to keep them alive. Sometimes you may want more flexibility in this behavior and wish to submit orders as live-until-cancelled. When orders are submitted as live-until
            Last edited by NinjaTrader_RyanM1; 06-16-2011, 10:18 AM.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Can the CancelOrder() method be used with Managed Order Handling?

              Comment


                #8
                Yes, CancelOrder can be used with the managed approach. The sample uses this.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Line 71 cancels entryorder but then Line 88 "
                  Replace entry limit order with a market order"

                  Why? What is the purpose of replacing with market order?

                  How would I use this CancelOrder() to cancel an ExitLongLimit(BuyProfit) and cancel an ExitLongStop(BuyStop), so I can EnterShortLimit()?

                  if (condition)
                  {
                  CancelOrder(BuyProfit);
                  CancelOrder(BuyStop);
                  EnterShortLimit();
                  }

                  ?????

                  Comment


                    #10
                    Originally posted by kenb2004 View Post
                    Ryan
                    You say "There's nothing inherent in limit orders that prevents them from being used to reverse", but when I use a market order in the very same instance both the ExitLongLimit and the ExitLongStop are cancelled automatically. But when I use Limit entry to reverse the order is ignored and the Exits are NOT cancelled. Why are the Exits not cancelled when using limit orders? How can the Exits be cancelled in order to reverse with a limit order?
                    This was rather extensively discussed in another thread that you might care to look at?

                    ref: http://www.ninjatrader.com/support/f...ad.php?t=39971

                    Comment


                      #11
                      koganam,

                      The symptoms are the same but you have a different issue - related to the timing of position updates in historical context.

                      Original poster is not seeing a limit order reversed due to internal order handling rules.
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_RyanM View Post
                        koganam,

                        The symptoms are the same but you have a different issue - related to the timing of position updates in historical context.

                        Original poster is not seeing a limit order reversed due to internal order handling rules.
                        Ryan, unfortunately no, it is not just a identity of symptoms: it is an identical issue. We are both trying to reverse using limit orders. In fact, even his thought processes are the same as mine were, in terms of canceling sitting orders before attempting to reverse on the bar on which the reversal condition occurs.

                        Comment


                          #13
                          Ryan
                          The point is the same. We need to be able to reverse with LimitOrders on the same bar just like Market orders. Whatever it takes to cancel any other Limit orders that were launched with the previous EntryLimit should be able to be cancelled the same way the Market Order does. Market orders loose too much in slippage and Unmanaged Order Handling is too involved.

                          You haven't answered my question from my previous post...

                          Comment


                            #14
                            Ken,

                            The sample provides an example on using CancelOrder(), mainly to illustrate structure of IOrders. It cancels the working order and submits a market order instead.

                            You can custom code the exact sequence and level of control you want.
                            Ryan M.NinjaTrader Customer Service

                            Comment


                              #15
                              Ryan
                              I posted an example code below. Will the code cancel the 2 working Limit Orders and reverse a long open position to a short position? Is there something else that needs to be added or what?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by haas88, 03-21-2024, 02:22 AM
                              18 responses
                              208 views
                              0 likes
                              Last Post haas88
                              by haas88
                               
                              Started by Board game geek, Today, 02:20 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post Board game geek  
                              Started by knighty6508, Today, 01:20 AM
                              2 responses
                              14 views
                              0 likes
                              Last Post knighty6508  
                              Started by franatas, Today, 01:53 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post franatas  
                              Started by knighty6508, Today, 01:17 AM
                              0 responses
                              9 views
                              0 likes
                              Last Post knighty6508  
                              Working...
                              X