Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order rejected

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

    #61
    Hello OldHatNoobCoder,

    Set the 'Parameter type' to Price, set the price to 99999
    Chelsea B.NinjaTrader Customer Service

    Comment


      #62
      Thanks.
      Click image for larger version  Name:	image.png Views:	0 Size:	14.3 KB ID:	1251277​​

      Comment


        #63
        Hello OldHatNoobCoder,

        This is showing the limit was rejected due to the OCOID. To confirm you are not submitted the replacement order through the account correct?

        If so, this is showing that even without submitting the order through the account the same error is occurring, and further shows with live orders your broker isn't rejecting orders that re-use OCOIDs from rejected/cancelled/filled orders and has different behavior than the Sim101 (or how NinjaTrader Brokerage works).
        Chelsea B.NinjaTrader Customer Service

        Comment


          #64
          Yep. Correct.

          Comment


            #65
            I changed the ordering of GetAtmStrategyStopTargetOrderStatus() and I was able to produce this error:
            Click image for larger version

Name:	image.png
Views:	195
Size:	19.1 KB
ID:	1251292

            Comment


              #66
              Hello OldHatNoobCoder,

              This occur typically occurs if this method is called before the entry order as filled and the Atm has become active. The warning in orange can be ignored if you are intentionally checking the stop and target status before the entry has filled and the Atm is active.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #67
                Hmm. When I place it later, nothing at all happens.
                Code:
                // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
                            if (status.GetLength(0) > 0)
                                {
                                    Print("The entry order average fill price is: " + status[0]);
                                    Print("The entry order filled amount is: " + status[1]);
                                    Print("The entry order order state is: " + status[2]);
                            // If the order state is terminal, reset the order id value
                            if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
                                orderId = string.Empty;
                                }
                            }
                        // If the stop order has been rejected, submit a new sell order
                            if (atmStrategyId.Length > 0)
                            {
                                bool stopOrderRejected = false;
                                string[,] stopOrders = GetAtmStrategyStopTargetOrderStatus("STOP1", atmStrategyId);
                
                                if (stopOrders.Length > 0)
                                {
                                    for (int i = 0; i < stopOrders.GetLength(0); i++)
                                       {
                                    if (stopOrders[i, 2].ToString() == "Rejected")
                                    {
                                        stopOrderRejected = true;
                                        Print ("Stop order rejected mofo ");
                                        break;
                                    }
                                }
                            }
                
                            if (stopOrderRejected)
                            {
                                double limitPrice = Close[0] - 10 * TickSize;
                                Order newLimitOrder = myAccount.CreateOrder(myInstrument, OrderAction.Sell, OrderType.Limit, OrderEntry.Automated, TimeInForce.Day, 1, limitPrice, 0, string.Empty, "NewLimitOrder", Core.Globals.MaxDate, null);
                                Account.Submit(new[] { newLimitOrder });
                            }    
                            // If the strategy has terminated reset the strategy id
                            else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
                                atmStrategyId = string.Empty;​

                Comment


                  #68
                  This occur typically occurs if this method is called before the entry order as filled and the Atm has become active. The warning in orange can be ignored if you are intentionally checking the stop and target status before the entry has filled and the Atm is active.
                  Also, the rejection messages were from the ATM strategy, and in that instance I was calling it before
                  Code:
                  // If the order state is terminal, reset the order id value
                  So as far as I know, this doesn't sound like it applies?

                  Comment


                    #69
                    Hello OldHatNoobCoder,

                    By 'place it later' do you mean you are calling the method later in time, or do you mean you are calling the method lower in the code? (An a new bar update would be later in time. lower in the code would be at the same time)

                    Before calling this are you checking that the GetAtmStrategyEntryOrderStatus() is returning as Filled?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #70
                      By 'place it later' do you mean you are calling the method later in time, or do you mean you are calling the method lower in the code?
                      I meant lower in the code.

                      Yes, just didn't paste that:
                      Code:
                       string[] status = GetAtmStrategyEntryOrderStatus(orderId);
                              // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements​[QUOTE][/QUOTE]

                      Comment


                        #71
                        Hello OldHatNoobCoder,

                        The logic should be requiring the status of the entry to be filled to check the stop and target status.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #72
                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hello Bruce,
                          You are referring to adding rejection handling logic to the SampleATMStrategy included with NinjaTrader?
                          Thank you for the suggestion. We will take this into consideration.
                          Thank you for talking in consideration the suggestion is very appreciated. I wander, has Ninjatrader then provided a Logic? I cannot find it anywhere.

                          I also have these some questions:

                          1)​
                          I tried to the code presented just here two paragraphs above on 05-11-2023, 08:54 AM and I tried different coding.

                          Basically I am never able to get any information with GetAtmStrategyStopTargetOrderStatus() no matter what I do. Whether the order gets rejected or the Stop and Target are active.

                          I always get
                          'GetAtmStrategyMarketPosition' method error: ATM strategy ID 'f7772ba8541d43eaa993147ded0ec9df' does not exist
                          'GetAtmStrategyStopTargetOrderStatus' method error: ATM strategy ID 'f7772ba8541d43eaa993147ded0ec9df' does not exist or is already in a terminated state

                          I am unable to get any stop/target information and I did all possible PrintOuts. I see OldHatNoobCoder tried.

                          I followed your recommendation above and I suspect that the problem is that I should provide the stop order ID instead of the atmStrategyId received by AtmStrategyCreate. Is that the reason? and if so, how do I get the order ID of the stop and target to be able to query them?

                          In the documentation for GetAtmStrategyStopTargetOrderStatus() I don't see an example.

                          2) If I get the ATM stop rejected in very fast market the ATM dies leaving me with exposed open position. Maybe the easiest solution to be compatible with NinjaTrader and Rithmic is to use CreateOrder. Can you indicate me a forum's thread that shows a way to track multiple different orders with a strategy that uses CreateOrder()?

                          3) Can you also indicate where I can find a way to monitor the ATM and close open position that are left exposed without bracket?

                          Best,
                          Gio
                          Last edited by giogio1; 12-09-2024, 06:16 AM.

                          Comment


                            #73
                            Hello Gio,

                            "I wander, has Ninjatrader then provided a Logic? I cannot find it anywhere."

                            Unfortunately, no, the SampleAtmStrategy example does not have logic to handle an order rejection.

                            "Basically I am never able to get any information with GetAtmStrategyStopTargetOrderStatus() no matter what I do. Whether the order gets rejected or the Stop and Target are active."

                            Please provide the print output showing the value of the isAtmStrategyCreated bool and the value of GetAtmStrategyEntryOrderStatus() (which requires supplying the entry order id).

                            "If I get the ATM stop rejected in very fast market the ATM dies leaving me with exposed open position. Maybe the easiest solution to be compatible with NinjaTrader and Rithmic is to use CreateOrder. Can you indicate me a forum's thread that shows a way to track multiple different orders with a strategy that uses CreateOrder()?"

                            Below is a link to examples, ProfitCaseStopTrailIndicatorExample and ProfitChaseStopTrailAddonExample that use Account.CreateOrder() and Account.Submit().

                            "Can you also indicate where I can find a way to monitor the ATM and close open position that are left exposed without bracket"

                            If an order submitted by an Atm is rejected, this would cause the Account.OrderUpdate event to update with the rejected order.
                            Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #74
                              Originally posted by NinjaTrader_ChelseaB View Post
                              Hello Gio,

                              If an order submitted by an Atm is rejected, this would cause the Account.OrderUpdate event to update with the rejected order.
                              https://developer.ninjatrader.com/do...op/orderupdate
                              Everything I have tested says this statement is untrue. The example link that ChelseaB has shown below this statement is not for an ATM template submitted order. It shows a stop and profit target added to an order. Order update does not seem to trigger from an Atm order change event, such as Stop rejected. Further, If the ATM is fully in place and you do a AtmStrategyStopTargetChange() to move the stop and the market moves too fast and you get the stop rejected. GetAtmStrategyStopTargetOrderStatus() will not read the correct value of the status. At least not from PLayback101 or Sim101. I have not found a way to directly read or detect a Stop Rejected from an atm submitted stop order. If anyone has been able to figure this one out Please share. Thanks

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by UsenKone, Today, 05:22 AM
                              0 responses
                              17 views
                              0 likes
                              Last Post UsenKone  
                              Started by saltminer, 07-07-2025, 01:43 PM
                              1 response
                              66 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by idude, 07-08-2025, 05:06 AM
                              0 responses
                              30 views
                              0 likes
                              Last Post idude
                              by idude
                               
                              Started by music_p13, 07-05-2025, 11:33 PM
                              1 response
                              45 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by gubbar924, 03-18-2018, 05:15 PM
                              43 responses
                              5,491 views
                              0 likes
                              Last Post ESMC377
                              by ESMC377
                               
                              Working...
                              X