Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order rejected

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

    #46
    Hello OldHatNoobCoder,

    To confirm, you received this error when testing the script I have provided you in post # 44?

    I am not referring to the limit price, I am referring to the quantity which cannot be 0. I guarantee this. You cannot submit an order with 0 quantity. Set the quantity to 1.

    Regarding the limitPrice, you can use 0 as the limit price for stop orders which do not have a limit price and thus the value is irrelevant. For a limit order is necessary to provide a value.

    "Alas, tried it and didn't change things.​"

    What did you try? What are you referring to as "it"?

    Are you referring to following the exact steps as shown in the video from post # 44?


    Regarding the OCOID error, it's very likely you are confused by what code is actually causing that error. If you remove the line of code to submit the order, does the error stop?

    I would expect this error for any limit order that was paired with a stop order that was rejected as the OCOID would not be valid for the limit. Meaning that error could be from the Atm Strategy and not from this new order you are submitting with <Account>.Submit().
    Chelsea B.NinjaTrader Customer Service

    Comment


      #47
      ​To confirm, you received this error when testing the script I have provided you in post # 44?​
      I misunderstood you, I had updated my own script with those changes. Now, testing the script you sent, yes it sends an order on every bar close.

      Regarding the OCOID error, it's very likely you are confused by what code is actually causing that error. If you remove the line of code to submit the order, does the error stop?
      I didn't get this error until I added this code to submit the order via <Account>.Submit()
      I removed the order code and still got the errors:
      Click image for larger version

Name:	image.png
Views:	254
Size:	11.8 KB
ID:	1251224

      I am not referring to the limit price, I am referring to the quantity which cannot be 0. I guarantee this. You cannot submit an order with 0 quantity. Set the quantity to 1.
      I understand that, wasn't saying I could send a 0 quantity order. I misrepresented my thinking there. But the idea is to send an order for whatever the quantity of the stop order was. And I didn't know why the order still sent as a 1 quantity regardless of whether I had 0 there or 1...see screenshot:
      ​​​Click image for larger version  Name:	image.png Views:	0 Size:	11.1 KB ID:	1251222
      Anyway, I wasn't questioning you, I changed it to 1.​
      Last edited by OldHatNoobCoder; 05-12-2023, 09:41 AM.

      Comment


        #48
        Hello OldHatNoobCoder,

        The error you are showing has an order that is using an OCOID of '96d4868377f642ecb5f4045f7b9b61c'.
        The order being submitted using string.Empty will not have that OCOID id.

        A stop loss and profit target are being submitted. If the stop is rejected, the profit target will also be rejected due to OCO.

        Go the Log tab of the Control Center. (Or print the order object in OnOrderUpdate() and provide the output)

        There is a sell stop order that was rejected. What is the OCOID of the sell stop order?
        Is there a profit target that was submitted with the same OCOID from the Atm?
        Was this the order that was rejected to due to the OCOID being re-used?
        What is the signalName of the order that was rejected?
        Is this the same signalName of the account submitted order?
        What is OCOID of the order with the signalName of the account submitted order?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #49
          I would expect this error for any limit order that was paired with a stop order that was rejected as the OCOID would not be valid for the limit. Meaning that error could be from the Atm Strategy and not from this new order you are submitting with <Account>.Submit()
          So we're back to...anything that references the atm strategy is not going to work, e.g., can't use GetAtmStrategyStopTargetOrderStatus() ...?

          Comment


            #50
            Hello OldHatNoobCoder,

            No, I have not stated that anything that references the atmStrategy is not going to work. Can you clarify specifically what I have said that you have interpreted this way so I may clarify my statement?

            Yes, you can use GetAtmStrategyStopTargetOrderStatus() to get the status of a rejected order. The error message is still going to appear. This does not change the state of the order for the code.

            I am attempting to get your attention that you are confusing which order is being rejected due to the OCOID being re-used. I am saying that it is not your account submitted order being rejected as you are suggesting, and is instead a profit target that is submitted with the stop loss from the Atm that is being rejected. Your replacement order is not being rejected. You are confusing the orders.

            As a test to make this simpler to understand, please use an Atm strategy with no profit target and only a stop loss. Set the profit target ticks to 0 in the Atm template and save this. Reference the new test template from the NinjaScript Strategy AtmStrategyCreate() method.
            Do you still see the error for the OCOID being re-used?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #51
              I am attempting to get your attention that you are confusing which order is being rejected due to the OCOID being re-used. I am saying that it is not your account submitted order being rejected as you are suggesting, and is instead a profit target that is submitted with the stop loss from the Atm that is being rejected. Your replacement order is not being rejected. You are confusing the orders.
              Our messages crossed in air. Wasn't implying you said this. Sorry. I was taking a guess as to why the sell limit order was getting rejected.

              I now see what you're saying about the target order. I assumed it was referring to my other order, since I never got the OCO error until I added that. See screenshot from logs before I implemented the GetAtmStrategyStopTargetIrderStatus():
              Click image for larger version

Name:	5.04.23.png
Views:	241
Size:	17.1 KB
ID:	1251259
              Those rejections are on two different accounts.

              vs now:
              Click image for larger version  Name:	5.12.23.png Views:	0 Size:	25.0 KB ID:	1251237

              Also, if I just manually run the same ATM Template and get a rejection of the stop, I don't get any other errors.
              Last edited by OldHatNoobCoder; 05-12-2023, 12:23 PM. Reason: redacted acct number

              Comment


                #52
                Hello OldHatNoobCoder,

                In the first screenshot, if the stop order was rejected first using the OCOID 'd547a2da09694f0682fc13afd5d4b2a4' I would have expected any profit target limit order using the same OCOID to also be rejected. If the profit target was accepted before the stop loss was rejected, then there wouldn't be an error for it.

                However, I cannot see which way the Log is sorted, and the seconds are shown in the time, so this screenshot cannot confirm that. Output from printing Account.OrderUpdate e.Order information would let us see the order these orders were submitted and in what order they updated.

                In general, if an stop loss is rejected, it is expected there will be an OCOID error for the profit target. Even with manual orders that are not submitted through code.

                With there being two errors, these are both stop orders on different accounts. So probably running two script instances on different accounts.

                With the orders on the Sim101, this is not a live account and is a local simulation account and the behavior may be different than your live brokerage.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #53
                  I don't think I had changed the sorting in the first screenshot, so it would be whatever the default sorting is, which appears to be newest at top. Can't be 100% sure I didn't change that, but I'm pretty sure I was just referencing everything by time without changing that.

                  For the second one, I didn't change sorting.

                  I don't think I can access that on old data (from may 4th), can I?

                  In general, if an stop loss is rejected, it is expected there will be an OCOID error for the profit target. Even with manual orders that are not submitted through code.
                  This hasn't been my experience, across a few hundred instances of stop rejection.

                  With there being two errors, these are both stop orders on different accounts. So probably running two script instances on different accounts.
                  Correct, but both scripts are a different version of the same (different ATM, different entry pricing)

                  With the orders on the Sim101, this is not a live account and is a local simulation account and the behavior may be different than your live brokerage.
                  Interesting. Obviously don't want to keep testing it on a live. I had only moved it to a live account because in testing I hadn't yet received a stop rejection. Thought I had it handled. Just blind luck.

                  Comment


                    #54
                    Hello OldHatNoobCoder,

                    It could be that your broker does not reject orders that are using invalid OCOIDs.

                    To confirm, you have tested on the Sim101 submitting an Atm with a stop order with an invalid price, the order was rejected, but the profit target was not rejected and remained working, is this correct?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #55
                      If I recall correctly, the PT order either gets canceled or doesn't get sent. Never seen the OCO error until now. But it doesn't stay a working order.

                      Comment


                        #56
                        Hello OldHatNoobCoder,

                        Please provide the output from prints, or provide a new screenshot of the Log tab of the Control Center showing the profit target order is being accepted and then cancelled after the stop loss has been rejected on the Sim101 account.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #57
                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hello OldHatNoobCoder,

                          Please provide the output from prints, or provide a new screenshot of the Log tab of the Control Center showing the profit target order is being accepted and then cancelled after the stop loss has been rejected on the Sim101 account.
                          Highlighted and color coded it just to make sure I was seeing it correctly

                          Click image for larger version

Name:	Log.png
Views:	239
Size:	49.5 KB
ID:	1251261

                          Comment


                            #58

                            Just noticed you wanted to see those specifically on the sim101 account. Might take me a bit to find/reproduce that.​

                            Comment


                              #59
                              Hello OldHatNoobCoder,

                              Correct, this should be on the Sim101 account.

                              Make an Atm template with a stop order using an invalid stop price (something way above the current price should work).
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #60
                                Originally posted by OldHatNoobCoder View Post
                                Make an Atm template with a stop order using an invalid stop price (something way above the current price should work).
                                How is that done? The smallest stop I can place in an ATM Template is 1. As far as I can see, I'm not able to create one with a negative stop (above entry price)

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                571 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                330 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
                                548 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                549 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X