No announcement yet.

Partner 728x90


Managed vs. UnManaged Trades

  • Filter
  • Time
  • Show
Clear All
new posts

    Managed vs. UnManaged Trades

    Hi -

    I am testing a new order management system using NT's simple MA strategy and I'm running into the "An Enter() method to submit an entry order....has been ignored" error. I can reproduce this issue. So, there's something systemic about how trade orders are being handled.

    First, here's the problem:
    (i) Sometimes ALL the Trade Set's orders get submitted and accepted OR (ii) ONLY the market order per trade set gets submitted and the limit orders don't get submitted for the trade set. A trade set contains 1x market order & 5 x limit orders invoked at the time of signal.

    - Timeframe: 3M, single timeframe
    - Asset: ES
    - Strategy: long and short
    - # Trades: 8 trades max per direction
    - Exit on session close

    My system trades in trade sets. A trade set contains 1 x market order and 5 x limit orders. The same for both longs and shorts.

    So, a long trade set uses the following Enter() methods:

    (1) entryOrder_1 = EnterLong(quantity_1, order_1);
    (2) entryOrder_2 = EnterLongLimit(0, true, quantity_2, order_2);
    (6) entryOrder_6 = EnterLongLimit(0, true, quantity_6, order_6);

    I've simplified the above but that captures the gist.

    (7) OnOrderUpdate(...) I save the Order object for future reference for each trade order for the trade set using the name of the order to then save the results in a Dictionary object.

    The problem appears to manifest itself after the first trade set.

    (a) The first trade for the 2 week timeframe I'm testing is short. So, 6 short trade orders are submitted and I can see all 6 trade orders when I trace order.ToString() OnOrderUpdate().
    (b) Some short orders get filled, some are "waiting" for the right "limit" price to get filled. So far, so good.
    (c) Long signal gets triggered
    (d) All 6 x short orders get submitted for cancelation
    (e) 1st long market order gets submitted -- and awaits the shorts to get closed
    (f) NONE of the other 5 x long limit orders get submitted -- error message
    (g) Error message: "An Enter() method to..."
    (h) All short positions and pending orders get closed or canceled
    (i) Long market order gets filled. None of the other long limit orders get submitted or filled.
    (j) Strategy continues to move forward
    (k) etc....

    So...Sometimes ALL the Trade Set's orders get submitted and accepted OR (ii) ONLY the market order per trade set gets submitted and filled and the limit orders don't get submitted.


    Big Surf
    Last edited by bigsurftrader; 03-15-2017, 11:00 AM.

    Selfishly bumping this ;-)

    Hoping NT can provide some clarity into issue of sequential market and limit orders that I am seeing.


      Hello bigsurftrader,

      Thank you for your note.

      You would not be able to submit both enter long limit and enter short limit orders at the same time due to Internal Order Handling Rules. You can view the Internal Order Handling Rules at the following link:

      If you wish to work with Unmanaged Orders you may do so and the orders would not be ignored in this case.

      Please let us know if you need further assistance.
      Alan P.NinjaTrader Customer Service


        Hi Alan -

        To clarify -- I only trade in one direction at a time. So, there won't be an instance of EnterLong and EnterShort being made on the same bar.


          What i'm referring to is:
          1x Market enter long
          5 x Limit enter long

          ...a few bars or hours later...

          Close long trades
          1x Market enter short
          5x Limit enter short


            If you can, please thoroughly read through the scenario I posted in the 1st post. It explains in detail how I'm able to replicate this issue.


              Here's a code example to reproduce the error using the NT "SampleMACrossOver":

              if (CrossAbove(SmaFast, SmaSlow, 1)){

              EnterLong(quantity, "Long_"+CurrentBar+"1");
              EnterLongLimit(0,true, quantity, GetCurrentBid()-.5,"Long_"+CurrentBar+"_2");
              EnterLongLimit(0,true, quantity, GetCurrentBid()-1,"Long_"+CurrentBar+"_3");
              EnterLongLimit(0,true, quantity, GetCurrentBid()-1.25,"Long_"+CurrentBar+"_4");
              EnterLongLimit(0,true, quantity, GetCurrentBid()-1.75,"Long_"+CurrentBar+"_5");

              else if (CrossBelow(SmaFast, SmaSlow, 1)){
              EnterShort(quantity, "Short_"+CurrentBar+"1");
              EnterShortLimit(0,true, quantity, GetCurrentBid()+.5,"Short_"+CurrentBar+"_2");
              EnterShortLimit(0,true, quantity, GetCurrentBid()+1,"Short_"+CurrentBar+"_3");
              EnterShortLimit(0,true, quantity, GetCurrentBid()+1.25,"Short_"+CurrentBar+"_4");
              EnterShortLimit(0,true, quantity, GetCurrentBid()+1.75,"Short_"+CurrentBar+"_5");

              To reproduce the error here are the Strategy Analyzer settings:

              I've attached an image.


                Here's the code with some order output-logging that clearly illustrates the problem I'm seeing.

                Code below:

                Order long1;
                Order long2;
                Order long3;
                Order long4;
                Order long5;

                Order short1;
                Order short2;
                Order short3;
                Order short4;
                Order short5;
                protected override void OnBarUpdate()
                if (CurrentBar < BarsRequiredToTrade)

                int quantity = 3;

                if (CrossAbove(SmaFast, SmaSlow, 1)){


                EnterLong(quantity, "Long_"+CurrentBar+"_1_");
                EnterLongLimit(0,true, quantity, GetCurrentBid()-.5,"Long_"+CurrentBar+"_2_");
                EnterLongLimit(0,true, quantity, GetCurrentBid()-1,"Long_"+CurrentBar+"_3_");
                EnterLongLimit(0,true, quantity, GetCurrentBid()-1.25,"Long_"+CurrentBar+"_4_");
                EnterLongLimit(0,true, quantity, GetCurrentBid()-1.75,"Long_"+CurrentBar+"_5_");

                else if (CrossBelow(SmaFast, SmaSlow, 1)){


                EnterShort(quantity, "Short_"+CurrentBar+"_1_");
                EnterShortLimit(0,true, quantity, GetCurrentBid()+.5,"Short_"+CurrentBar+"_2_");
                EnterShortLimit(0,true, quantity, GetCurrentBid()+1,"Short_"+CurrentBar+"_3_");
                EnterShortLimit(0,true, quantity, GetCurrentBid()+1.25,"Short_"+CurrentBar+"_4_");
                EnterShortLimit(0,true, quantity, GetCurrentBid()+1.75,"Short_"+CurrentBar+"_5_");

                protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)

                // if entry order exists
                if (order != null)
                // Order Submitted and Accepted by broker, update the Order object
                if (orderState == OrderState.Accepted && (order.OrderAction == OrderAction.Buy)){

                if (order.Name.Contains("_1_")){
                long1 = order;
                Print("long order 1 assigned");
                else if (order.Name.Contains("_2_")){
                long2 = order;
                Print("long order 2 assigned");
                else if (order.Name.Contains("_3_")){
                long3 = order;
                Print("long order 3 assigned");
                else if (order.Name.Contains("_4_")){
                long4 = order;
                Print("long order 4 assigned");
                else if (order.Name.Contains("_5_")){
                long5 = order;
                Print("long order 5 assigned");

                if (orderState == OrderState.Accepted && (order.OrderAction == OrderAction.SellShort)){

                if (order.Name.Contains("_1_"))
                short1 = order;
                else if (order.Name.Contains("_2_"))
                short2 = order;
                else if (order.Name.Contains("_3_"))
                short3 = order;
                else if (order.Name.Contains("_4_"))
                short4 = order;
                else if (order.Name.Contains("_5_"))
                short5 = order;



                  Hello bigsurftrader,

                  Under the following link, see Internal Order Handling Rules that Reduce Unwanted Positions.

                  I have attached a sample strategy which I suggest you apply to a 5 second chart and enable chart trader so you can see the limit orders working. The strategy opens a position using a market long order and submits long limit orders below the market. After 3 bars pass, an entershort method is called along with EnterShortLimit call, the latter is ignored and logs the following message,

                  Strategy 'MyCustomStrategy6/100895805': An Enter() method to submit an entry order at '3/16/2017 8:57:05 AM' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.
                  This is expected and explained in the link above. To do what you’re trying to do you should use the unmanaged order method,

                  Please let us know if you need further assistance.
                  Attached Files
                  Alan P.NinjaTrader Customer Service


                    Thanks Alan. I'll take a look...


                      Alan - I've read the managed and unmanaged documentation through multiple times. So It's probably not clear to me which portion of the "managed" rules I'm violating. Could you help explain to me or highlight the area/sentences?



                        Thanks for all your help Alan. No need to reply to this post and my questions.

                        I'm converting my code to the Unmanaged approach 100% and I actually prefer this method over the Managed approach because of the transparency/control of the trade orders and positions.

                        Thank you once again!!


                        Latest Posts


                        Topics Statistics Last Post
                        Started by ghiasi123, Today, 10:17 AM
                        1 response
                        Last Post NinjaTrader_Zachary  
                        Started by demarcog, Today, 09:50 AM
                        1 response
                        Last Post NinjaTrader_ChrisL  
                        Started by Martin89, Today, 09:53 AM
                        0 responses
                        Last Post Martin89  
                        Started by timmbbo, Today, 09:10 AM
                        1 response
                        Last Post NinjaTrader_Manfred  
                        Started by space_trader, 11-26-2020, 05:06 AM
                        2 responses
                        1 like
                        Last Post klaus w
                        by klaus w