Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancellation rejected by the Order Management System - Order is complete...

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

    #16
    Hello Brandon,

    Thank you for the detailed response.

    I would get a rejection if I'm trying to set a stop at the wrong price, but, in this case it is more of a message that the order could not be cancelled, in that case, how can I detect that I got the message "Cancellation rejected by the Order Management System" within Ninjascript?

    Regards
    Ulises
    ulisesguerrero
    NinjaTrader Ecosystem Vendor - Thrifty Coders

    Comment


      #17
      Hello ulisesguerrero,

      Thanks for your note.

      The error code for this type of rejection would likely be ErrorCode.UnableToCancelOrder.

      You could check for the ErrorCode in the OnOrderUpdate() method when the 'Cancellation rejected' error message occurs to confirm the ErrorCode.

      See this help guide page for more information about the 'ErrorCode error' parameter OnOrderUpdate(): https://ninjatrader.com/support/help...rderupdate.htm

      Let me know if I may assist further.
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment


        #18
        Hello Brandon,

        I tried using CancelOrder as you suggested to first remove the stop before calling ExitLong, but the orders are completely unaffected by it. I guess it doesn't work in Managed Mode for orders that were created with Set?

        How can I cancel the stop loss then?

        Regards
        Ulises
        ulisesguerrero
        NinjaTrader Ecosystem Vendor - Thrifty Coders

        Comment


          #19
          Hello ulisesguerrero,

          Thanks for your note.

          You would need to use Exit methods in your script instead of Set methods to place your stop loss and profit target orders. Then, you could assign the Exit method to an order object and call CancelOrder() on that order object.

          For example, ExitLongLimit could be used instead of SetProfitTarget to place profit target orders. ExitLongStopLimit could be used instead of SetStopLoss to place stop loss orders.

          See this reference sample which demonstrates using CancelOrder(): https://ninjatrader.com/support/help...thod_to_ca.htm

          Please let me know if I may assist further.
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #20
            Hello Brandon,

            Defeats the purpose of the whole managed orders, need to change so much code, just because when I call ExitLong() it can't cancel the stop first. That is a risk that would be there for any strategy with the stop being close to exit price.

            Now I need to have timers, monitor all orders, and so much extra code to fix a simple issue.

            I'm thinking that would be a small change in the logic of the managed order system, can you please add as a feature request as it is such a basic functionality?

            Regards
            Ulises
            ulisesguerrero
            NinjaTrader Ecosystem Vendor - Thrifty Coders

            Comment


              #21
              Hello ulisesguerrero,

              Thanks for your note.

              As previously stated, "..the Managed Approach for order entry can be further broken down into a Basic/Common Managed approach and a more Advanced Managed approach. This type of strategy would fall under the Advanced Managed Approach which would require you to track order objects using the Order class."

              Advanced Managed Approach strategies will require you to create more complex logic in your strategy compared to a Basic Managed Approach strategy. This could require tracking order objects to monitor each order being placed by the script. It also could entail calling Exit methods to place stop loss and profit target orders, such as ExitLongLimit, instead of using Set methods like SetProfitTarget. And, the strategy's logic would need to be debugged by you to ensure that your logic works as you expected. Detailed debugging information could be found linked below.

              https://ninjatrader.com/support/foru...121#post791121

              I understand that you are placing a stop loss using Set methods and cannot cancel the stop before ExitLong() is called in your script. You would need to use Exit methods in your script instead of Set methods to place your stop loss and profit target orders. Then, you could assign the Exit method to an order object and call CancelOrder() on that order object.

              For example, ExitLongLimit could be used instead of SetProfitTarget to place profit target orders. ExitLongStopLimit could be used instead of SetStopLoss to place stop loss orders.

              See this reference sample which demonstrates using CancelOrder(): https://ninjatrader.com/support/help...thod_to_ca.htm

              Also, see the attached example script demonstrating placing stop loss and profit target orders using Exit methods.

              Let me now if I may assist further.
              Attached Files
              Last edited by NinjaTrader_BrandonH; 08-05-2022, 08:07 AM.
              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

              Comment


                #22
                Hello Brandon,

                That is an overkill solution.

                Fortunately I found a much easier way. I simply use the SetProfitTarget to move the target to the opposite side of the market, and then exits properly, as it is OCO with the stop loss.
                Only disadvantage is that even on a loss it says "Profit target", but at least there's no need for extra 200+ lines of code for a simple exit.

                Regards
                Ulises
                ulisesguerrero
                NinjaTrader Ecosystem Vendor - Thrifty Coders

                Comment


                  #23
                  Upon deeper research, the NT8 - Rithmic connection doesn't support OCO orders on the server side. Therefore any glitches with NT or internet, will cause unwanted open positions without a stop loss. Will have to completely remove Take Profit from all positions.
                  ulisesguerrero
                  NinjaTrader Ecosystem Vendor - Thrifty Coders

                  Comment


                    #24
                    Sorry to hear you're having trouble with the cancellation rejection in your Order Management System. It can be frustrating when things don't go as planned, right? Your code seems straightforward, so let's try to troubleshoot together. Have you checked if there are any specific error codes accompanying the rejection? That might give us a clue. Also, make sure you're running the latest version of NT8 and that your broker connection is stable. On a side note, if you want to improve your product management, try this product management system. It's a game-changer for efficient team collaboration and management.
                    Last edited by NathanNels; 06-19-2023, 10:04 AM.

                    Comment

                    Latest Posts

                    Collapse

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