Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order rejected

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

    #16
    You can't (or shouldn't) mix and match between these managed order methods like ExitLong() and ATM strategy methods - at least not at the same time or in the same trade. You need to settle on one or the other approach.
    Thanks. Please bear with me, as I'm just learning and using what I can find on the NT site and forums. I wasn't aware I was breaking a convention by mix-matching those. I assumed this was the way to handle it since I didn't find anything under ATM Strategy Methods that gives me a way to exit a position when the OCO orders are gone.

    This is an important thing to handle that comes up often in my tests (anytime NQ moves rapidly through a range and hits my entry, for example). So I took a shot with this. Is there a proper way to exit this "orphaned" ATM position under ATM Strategy Methods?

    I could be misunderstanding this, but I also didn't see why it would need to be an ATM Strategy Method at that point, since the ATM Strategy is terminated (*correct terminology?) once the bracket orders are gone, even though the position remains.

    Thanks again for your help and patience.

    Comment


      #17
      You can close a running ATM with https://ninjatrader.com/support/help...ategyclose.htm
      Bruce DeVault
      QuantKey Trading Vendor Services
      NinjaTrader Ecosystem Vendor - QuantKey

      Comment


        #18
        I am using that mthod effectively in the same script for a different purpose:
        Code:
        // Cancel all orders and flatten positions at 3:49 PM EST
        if (serverTimeInEastern.TimeOfDay >= new TimeSpan(15, 49, 0))
        {
        AtmStrategyCancelEntryOrder(atmStrategyId)
        AtmStrategyClose(atmStrategyId);
        }
        However, when I tried to use AtmStrategyClose(atmStrategyId) to close the position in the situation I've discussed, it didn't work. Nothing happened, and this code printed that the AtmStrategyMarketPosition is flat, which to me explained why it won't close the position:
        Code:
        Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));

        Comment


          #19
          If you entered with an ATM, and are flat from the perspective of the ATM, how are you still in a position? Did you enter any additional size using managed or unmanaged strategy orders? If that is the case, you should use managed or unmanaged strategy orders (depending on how you entered) to exit that same position. ATMs and strategy orders do not see each other at all.

          You mention above that the ATM position is "orphaned" which suggests you did enter only with an ATM but that somehow the ATM position became flat yet the account position was not flat. If that is the case, could you elaborate on how that happened? Did you maybe cancel the exit orders of the ATM or reduce their size?
          Bruce DeVault
          QuantKey Trading Vendor Services
          NinjaTrader Ecosystem Vendor - QuantKey

          Comment


            #20
            If you entered with an ATM, and are flat from the perspective of the ATM, how are you still in a position?
            That's a great question. I don't know why I'm flat from the perspective of the ATM. I don't want to point fingers, but it seems to be a flaw in the platform.

            Did you enter any additional size using managed or unmanaged strategy orders?
            No. I'm not placing any other orders. This is an atm strategy only. When the stop gets rejected because the market has moved past it, the position is left open but without OCO orders. That is all that is happening. For what it's worth, this also happens when running ATM orders manually, it is not a strategy-related issue.

            You mention above that the ATM position is "orphaned" which suggests you did enter only with an ATM but that somehow the ATM position became flat yet the account position was not flat. If that is the case, could you elaborate on how that happened? Did you maybe cancel the exit orders of the ATM or reduce their size?
            Answered above for the most part. I don't know how or why the ATM position is considered flat once the OCO orders are gone (due to a rejection of the stop), but that's what seems to happen.
            Last edited by OldHatNoobCoder; 05-07-2023, 07:20 AM.

            Comment


              #21
              I think you should look at the sequence of events in your orders tab or log tab of control center and/or the log and trace files in Documents -> NinjaTrader 8 -> log and Documents -> NinjaTrader 8 -> trace and get to the bottom of what the sequence of events was. You need to understand how it is happening so support and/or other users can help you figure out how to stop it from happening or properly address it when it does.
              Bruce DeVault
              QuantKey Trading Vendor Services
              NinjaTrader Ecosystem Vendor - QuantKey

              Comment


                #22
                I think you should look at the sequence of events in your orders tab or log tab of control center and/or the log and trace files in Documents -> NinjaTrader 8 -> log and Documents -> NinjaTrader 8 -> trace and get to the bottom of what the sequence of events was.
                I did that before I ever posted on this thread. I understand what the sequence of events is. It's quite clear in the log and in the orders tab. Next time I will take screenshots. I have not reached out directly to NT support, but perhaps I should do that.

                I'm also upgrading my VPS this weekend, so that will hopefully eliminate some of the rejected stop orders, but probably not all.

                Comment


                  #23
                  If you have rejected stop orders, are you checking that the price is not across the market before you change the price of an existing order? You have to always check if the stop would cross the market before you change its price. If it would cross the market, instead of changing the stop's price, use AtmStrategyClose().
                  Bruce DeVault
                  QuantKey Trading Vendor Services
                  NinjaTrader Ecosystem Vendor - QuantKey

                  Comment


                    #24
                    That is most often seen with trailing stops. When it's going to be trailed up programmatically, just check if it's immediately marketable - if it is, AtmStrategyClose() and if not you can move it. There is still a SMALLER chance it will be rejected because the market could move while you're sending it.
                    Bruce DeVault
                    QuantKey Trading Vendor Services
                    NinjaTrader Ecosystem Vendor - QuantKey

                    Comment


                      #25
                      If you have rejected stop orders, are you checking that the price is not across the market before you change the price of an existing order? You have to always check if the stop would cross the market before you change its price. If it would cross the market, instead of changing the stop's price, use AtmStrategyClose().
                      This is the stop order that is automatically sent by the ATM Template when the entry order of the ATM Template is filled. Yes, this is happening when the market has moved rapidly and price has crossed through the price of that stop order in the milliseconds before the stop order is sent.

                      That is most often seen with trailing stops. When it's going to be trailed up programmatically, just check if it's immediately marketable - if it is, AtmStrategyClose() and if not you can move it. There is still a SMALLER chance it will be rejected because the market could move while you're sending it.
                      I do have some strategies with trailing stops, but that is not what this is about.

                      And with the trailing stop, it is less of a problem, since it's a stop order modification that gets rejected, not the original stop order of the ATM. So there's at least still a stop order present and the trade closes as it should, albeit at a less favorable price.

                      But again, that is not the case I'm trying to solve here.
                      Last edited by OldHatNoobCoder; 05-07-2023, 11:53 AM.

                      Comment


                        #26
                        Okay, hopefully NinjaTrader Support can advise if this is a known issue or how to go about getting it resolved.
                        Bruce DeVault
                        QuantKey Trading Vendor Services
                        NinjaTrader Ecosystem Vendor - QuantKey

                        Comment


                          #27
                          Hello OldHatNoobCoder,

                          The behavior from using Atm Strategy methods is the same as manual trading.

                          If you have the stop loss set to an invalid price in the template, and place a manual entry order, and the stop loss is rejected, the position on the account will stay open, but the atm strategy is now no longer valid and is closed (which shows flat) and the account position is unprotected.
                          At this point you would need to manually exit the account position with a manual order because the atm is no longer running.
                          Go ahead and give this a try manually to see the behavior.

                          In code, you would need to submit an order to the account directly using the Addon approach if you want to close that position.
                          https://ninjatrader.com/support/help...nt8/submit.htm
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #28
                            Thanks Chelsea.

                            In code, you would need to submit an order to the account directly using the Addon approach if you want to close that position.
                            How would I trigger this in code, though, since the position is "flat" at that point?

                            This seems to be the answer I was looking for, which is simply that this can't be done. Because based on this discussion there doesn't seem to be a way for the script to know that a position from an ATM strategy is still open, since cancelling the exit orders makes it "flat".

                            If you accept feature suggestions, I'd add this to your list. I'm not the only trader who has issues with this phenomenon in manual trading, I've talked with many others about it. Seems faulty that the position is considered closed when it isn't closed. I don't know if that can be "fixed". But perhaps it could be changed so that in ATM Template setup there is an option, perhaps a toggle option, to send a market exit order in the event of a rejection.

                            Exiting manually is an option, of course, but not a good one, and it often costs the trader money. Furthermore, you have to click OK on the rejection dialog window before you can do this, slowing down manual handling even more. Eliminating that requirement would also be helpful. If you're trading multiple accounts via copier add-on, you have to click OK on several windows, costing more precious time.

                            Just my .02
                            Last edited by OldHatNoobCoder; 05-08-2023, 08:42 AM.

                            Comment


                              #29
                              Hello OldHatNoobCoder,

                              The order would be submitted to the account with <Account>.CreateOrder() and <Account>.Submit().

                              The help guide linked in post # 27 has sample code.
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #30
                                NinjaTrader_ChelseaB Maybe it would be great to update one of the "how to make an ATM-type strategy" examples to include handling to exit an unexpected position with no exits by doing exactly this... that would be a service to the community.
                                Bruce DeVault
                                QuantKey Trading Vendor Services
                                NinjaTrader Ecosystem Vendor - QuantKey

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                557 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                324 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                101 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                545 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                547 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X