Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reverse Issue

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

    Reverse Issue

    Hello,

    I have a custom strategy running on a chart. Everything works as it should, until I try and reverse the position. A reverse situation occurs rarely.

    Hopefully someone can help me find the flaw in my logic.

    I am using IOrders for the entry, target and stop orders. The order variables are:

    entryOrder for entry, stop limit
    targetOrder for target, limit
    stopOrder for stop, market

    My thought was to create two order entry ID's and alternate between them.

    entryOrder one is placed with "entry ID #1". If the order fills, a targetOrder and stopOrder are generated tied to "entry ID #1". After the target and stop orders are placed in the OnExecution section of code "entry ID #2" is set as the next available entry ID.

    If a reverse situation occurs entryOrder two is placed in the opposite direction with "entry ID #2". I don't want to simply double my stop order, because it is a market order, and I only want to enter with Stop Limit Orders.

    I have tried selecting UniqueEntries and 2 for Entries per Direction when starting the strategy.

    The order is fired, but nothing happens and in the log section I get a message that the Enter() command has been ignored, see order handling rules.

    Even though entryOrder is null after it is filled, is it still tied to the original position, even though the string entry name is different?

    Thanks in advance,

    Tiara

    #2
    The rules are there to prevent overfills. Do not forget that when you go EnterShort after you already have a long position, NT will automatically first close your long position then reverse you into your short position. Problem is you already have stop/targets in place. A dangerous situation is that your stop/targets get filled, your EnterShort still closes the long position, you enter short. Now you are essentially double the short position you wanted. This is why it is not allowed. What you need to do is cancel your stop and your target order. Wait until they have fully cancelled, then you can submit your EnterShort().
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Follow Up

      Josh,

      Thanks for the quick reply.

      Are you saying that an EnterShort will close and reverse the position? If the EnterShort for 1 contract is issued and I am currently long 1 contract, would it flatten the position or flatten and go short?

      Thanks,

      Tiara

      Comment


        #4
        Yes, that is how it works.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Clearer Understanding

          Hello,

          Still struggling with this reversal issue.

          Aren't you creating the possibility of the very thing you are trying to prevent, by first closing a long position on a EnterShort command? The situation of being short 2 contracts that you bring up, would be one that your logic has created. If I follow your advice and cancel my stop market order & target order and place the enter short order, what happens if the price is never reached and the market turns back towards my target, which is now cancelled?

          I don't see the logic in having the EnterShort both close the old and enter a new position. It really handicaps us traders.

          I have been trading 4 live auto systems for over 7 months without issue, using esignal to send orders to Ninja. I am trying to eliminate esignal and the delay issues associated with that arrangement.

          Currently, I enter a position and immediately generate a stop market and target with OCO. If a reverse situation develops, I simply initiate a new, unrelated order to go the other direction. I handle each "trade" seperately. It's that simple. The only way I could be left hanging is if my stop neglected to fill, and in that case I would be flat.

          Unless I am understanding things wrong, I don't see how it is possible to exit a current trade with a stop market, enter in the other direction with a stop limit and cancel the target if that situation occurs.

          If I am forced to wait until my stop fills, and the target is cancelled before placing a limit order, my fill rate will drop dramatically in fast markets.

          Thanks for any light you can shine on this issue,

          Tiara

          Comment


            #6
            tiara50,

            I am not following you. EnterShort closes your long and then gets you short. If you want to just close your long use ExitLong. If you are using market orders you will not hit any Internal Order Handling Rules. The rules are in place to prevent overfills.

            I do not understand what you mean wait for your stop to fill and your limit to cancel. All of that is handled by your code. Which order are you concerned about?
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Josh,

              I want to exit the current position via market order, and enter the new position via stop limit order.

              My problem is that the reverse signal may not trigger until the price is close to getting reached, and if I try and cancel the stop and issue a new enter short command it may be too late.

              Thanks,

              Tiara

              Comment


                #8
                Hi Tiara, then just use ExitLong() to exit your trade and check for the position to be closed. Then you can go ahead and place the reversal entry with your EnterShortStopLimit() order.

                Comment


                  #9
                  Bertrand,

                  In fast markets that won't work.

                  There has to be a way to have an order in to close a current position AND another order to enter a new position at the same time, without violating any rules? I currently am doing this without issue, by sending the trade commands to Ninja from eSignal. The problem is the commands that are available to me in eSignal, are not available in a Ninja strategy, from what I understand.

                  The potential overfill safe gaurd is only a possibility because the Enter... command closes the open position first. It appears to me that you are creating the possibility of the very situation that you are trying to prevent.

                  Thanks,
                  Tiara

                  Comment


                    #10
                    Tiara,

                    There is no other way. I do not understand why you think checking for a close creates any chance for an overfill. It is quite the opposite. If you do not check you will get an overfill.

                    You have two options:
                    1. You need to exit market, check for close, enter your stop limit.
                    2. Cancel stop loss/profit target, check for cancel, enter reversal
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Josh,

                      Thanks for making it clear what the available options are. No one to date has said what I am trying to do can't be done in a Ninja strategy. They've only suggest other ways.

                      My comment regarding the possible overfill situation was based on the fact that in a situation where there was a stop order in place and an opposite direction entry order, by the Enter... command first closing the position, that in and of itself creates the possibility for an over fill. I realize that you do not allow the above, now.

                      As to checking for close first, in a fast market my fill rate will drop dramatically, as my exit and entry prices are the same. So, if I wait to confirm my exit and then submit a limit order, it will more than likely move by me and not fill my entry.

                      So, if Enter.... closes the position first, in an EnterStopLimit... situation, does it close the current position with a stop limit order or market order? I realize it would enter the new position with a limit order.

                      Thanks,
                      Tiara

                      Comment


                        #12
                        It will do it with a stop limit order.
                        Josh P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        649 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        370 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        109 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        573 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        576 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X