Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why cannot reverse Entry orders execute on the same bar as exit orders?

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

    Why cannot reverse Entry orders execute on the same bar as exit orders?

    I decided to code a reversal using a limit order instead of a market order, so I coded this:
    Code:
    		private bool _boolReverseOnOppositeSignal	= true;
    
                    CalculateOnBarClose = true.
    		private void GoShort(string strEntryName)
    			{
    				if (this._boolReverseOnOppositeSignal) ExitLong();
    				EnterShortLimit(DefaultQuantity, Close[0], strEntryName);
                            }
    However, when the conditions are correct, and I call the GoShort() function, with an entryName, the position is closed, as I expect, but the opposing entry order is never issued or executed. What would be the problem here? I really want to exit with a market order, then place a limit order for the opposite direction: I do not want to reverse instantly with a market order.

    I had already seen that the strategy would not reverse on the EnterLimit(), if I did not actually flatten first, but it seems that even if I flatten, the second order is never sent anyway.
    Last edited by koganam; 04-05-2011, 02:31 AM.

    #2
    koganam, have you checked what the TraceOrders output is showing why the second order is not sent? You're likely running into the internal order handling rules here - http://www.ninjatrader.com/support/h...d_approach.htm
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      koganam, have you checked what the TraceOrders output is showing why the second order is not sent? You're likely running into the internal order handling rules here - http://www.ninjatrader.com/support/h...d_approach.htm
      I guess I will turn TraceOrders on, and take another look before I offer any more comments.

      Thanks.

      Comment


        #4
        Maybe we need some new OrderTypes ?

        Originally posted by NinjaTrader_Bertrand View Post
        koganam, have you checked what the TraceOrders output is showing why the second order is not sent? You're likely running into the internal order handling rules here - http://www.ninjatrader.com/support/h...d_approach.htm
        After turning on TraceOrders, I think I have began to understand why NinjaTrader does not allow an Exit() immediately followed by a reverse entry on the same tick, which essentially is what is happening if CalculateOnBarClose is true.

        I have begin to get the last pieces together for a function to do what I want. (It seems to work correctly, so now comes the extensive anal-retentive testing that I do to ensure that I can simulate all conditions and get it working right).

        However, I think this whole little thread, and this bigger one (http://www.ninjatrader.com/support/f...31243#poststop), now point to what I think is a need for new OrderTypes in NinjaTrader. May I suggest the following, self-explanatory, (as yet more) new order types.

        ReverseToLong()
        ReverseToShort()
        ReverseToLongLimit()
        ReverseToShortLimit().

        Why not just Reverse() and ReverseLimit()? By specifying the direction, they act as safety checks. The wrong reversal will generally be disastrous. Of course, we could just use the 2 simpler ones anyway, and NinjaTrader use internal rules to ensure that the wrong reversal cannot occur.
        Last edited by koganam; 04-11-2011, 07:21 AM.

        Comment


          #5
          Thanks for those suggestions koganam, however I'm not 100% sure I follow you - the Enter() methods would reverse for you if needed, however that would not eliminate the the considerations made for implementing the order handling rules.
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Bertrand View Post
            Thanks for those suggestions koganam, however I'm not 100% sure I follow you - the Enter() methods would reverse for you if needed, however that would not eliminate the the considerations made for implementing the order handling rules.
            No they do not. Please look at the query that started this thread. I have provided the code there. It does not reverse. It exits, and the reversal order is never placed.

            The only entry methods that reverse you automatically are market orders. I have stated clearly that I never enter the market with a market order: I only exit with them, if necessary. In this case the exit is with a market order.

            The following limit order is never placed after the Exit order. As the reversal condition is valid on only the bar that it occurs on, in effect, the reversal order is never placed.

            Comment


              #7
              This is not correct, all entry methods would attempt to reverse - in your case this is 'ignored' as the the position update is not reflected on the same tick and thus you would run into the mentioned order entry rules here - perhaps take a look at the unmanaged approach that would not have this rules present and therefore would offer more flexibility to code exactly whay you would need -

              BertrandNinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Bertrand View Post
                ...- in your case this is 'ignored' as the the position update is not reflected on the same tick ...
                Granted. I believe that I said pretty much exactly that when I said this:
                ... NinjaTrader does not allow an Exit() immediately followed by a reverse entry on the same tick, which essentially is what is happening if CalculateOnBarClose is true.
                up from my response after I turned on TraceOrders.

                Yes, I know that the unmamaged approach gives me near ultimate flexibility, so that is certainly a viable option. I have even managed to finagle something together that allows me to do it with a managed approach. However, as the other thread that I quoted shows, I am not the only one who would like to reverse on the same candle with LimitOrders while using a managed approach, so that we do not have to worry about coding the internal order handling details.

                Regardless, your answer means that there are situations in which the current Limit order types cannot or will not reverse the position on the same candle. Actually they never will: they require 2 candles to reverse, if CalculateOnBarClose is true; as, per your own words, the reverse entry order is ignored, because the position update is not yet reflected, on that same tick that closes the candle.

                This is not a quibbling point. It describes a real situation. It would appear that it is the sensible, safety, order-handling rules that make it necessary to have a specific order type for reversals. All in all, the current Enter() rules cannot reverse one on the same candle if CalculateOnBarClose is true: your escape clause, "however that would not eliminate the the considerations made for implementing the order handling rules." is operational.

                Comment


                  #9
                  koganam,

                  We understand you may want to try this from a managed approach, but there are many internal tracking issues that would arise which is why this is not possible from a managed approach. That is why it the restriction is in place.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Josh View Post
                    koganam,

                    We understand you may want to try this from a managed approach, but there are many internal tracking issues that would arise which is why this is not possible from a managed approach. That is why it the restriction is in place.
                    I believe I said as much, about my understanding why the restriction is in place. Am I to presume then that your response is just a polite way to tell me: "It is not possible for NinjaTrader developers to specifically code a new OrderType for a managed one-candle reversal if CalculateOnBarClose is true, so I should please just shut the hell up" ? You do reversals right now with Mar****rders. What makes is so impossible to do with LimitOrders?
                    Last edited by koganam; 04-11-2011, 02:31 PM.

                    Comment


                      #11
                      koganam,

                      Without getting into all the internal technicalities, it isn't possible at this point in time. There are lots of internal tracking issues, overfill risks, etc. at play. It is for this exact purpose (among others) that we introduced the unmanaged approach. With the managed approach, the purpose is to provide a clean, easy-to-use approach to order submission/management. To achieve this unfortunately does come with limitations like this.

                      With that being said, expanding the scope of what is possible with the managed approach is on our list, but this is absolutely not a trivial task as simple as just putting in a new order type. Treading lightly is an understatement to what is necessary for any changes/improvements in this area.
                      Josh P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Felix Reichert, 04-26-2024, 02:12 PM
                      11 responses
                      71 views
                      0 likes
                      Last Post Felix Reichert  
                      Started by junkone, 04-28-2024, 02:19 PM
                      7 responses
                      78 views
                      1 like
                      Last Post junkone
                      by junkone
                       
                      Started by pechtri, 06-22-2023, 02:31 AM
                      11 responses
                      135 views
                      0 likes
                      Last Post Nyman
                      by Nyman
                       
                      Started by ageeholdings, 05-01-2024, 05:22 AM
                      4 responses
                      27 views
                      0 likes
                      Last Post ageeholdings  
                      Started by hdge4u, 04-29-2024, 12:23 PM
                      4 responses
                      22 views
                      0 likes
                      Last Post NinjaTrader_RyanS  
                      Working...
                      X