• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Submission rejected???

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

    Submission rejected???

    I get this error msg when trying to Submit the TrailStop order (the current market position is Short): "Buy stop or buy stop limit order can't be placed below the market affected Order: Buy 5 StopMarket @ 0"

    NOTE: there is a 3-tick separation in the /ES between the TrailStop and its triggering price level.

    Going thru the Output window shows the price for the TrailStop order has a proper price (which is not zero) above the Stop1 price (which, when filled, created a market Short position and triggered the Submit of the TrailStop order). What am I doing wrong here?

    This error also occurs if I use a Strategy (vs. an Indicator) for my AddOn code. I have attached the Indicator code.
    Attached Files
    Last edited by ronhb107; 02-08-2018, 01:30 PM.

    #2
    Hello ronhb107,

    What is the specific line of code causing the error?

    What is the print that is printing the price just before the order is placed?

    What is the output from the print?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I am now using a price a tick away from the Entry price (just to see if being within the Entry and Stop1 was causing the problem) and the problem persists.

      Here's the Output screen where the rejection occurs...

      Code:
      ClearOrders   account: Sim101  Orders count: 11
      startAt: 2/8/2018 2:54:04 PM
      ClearOrders  -  Order name: Entry OrderState: Filled  Price: 2623.75  Quantity: 1  Filled: 1  Time: 02/08/2018 14:54:04.870
      ClearOrders  -  Order name: Stop1 OrderState: Filled  Price: 2622.75  Quantity: 6  Filled: 6  Time: 02/08/2018 14:54:10.230
      ClearOrders - Submit trailStop.Quantity: 5
      OnOrderUpdate - OrderName: TrailStop Price: 2624.25  Quantity: 5  Filled Qty: 0  OrderState: Submitted  Time: 02/08/2018 14:54:10.300
      OnOrderUpdate - OrderName: TrailStop Price: 2624.25  Quantity: 5  Filled Qty: 0  OrderState: Rejected  Time: 02/08/2018 14:54:10.303
      ClearOrders  -  Order name: Target1 OrderState: CancelSubmitted  Price: 2624.5  Quantity: 1  Filled: 0  Time: 02/08/2018 14:54:10.239
      ClearOrders  -  Order name: stopTarget OrderState: Working  Price: 2622.25  Quantity: 5  Filled: 0  Time: 02/08/2018 14:54:05.053
      ClearOrders  -  Order name: TrailStop OrderState: Rejected  Price: 2624.25  Quantity: 5  Filled: 0  Time: 02/08/2018 14:54:10.300
      ClearOrders count: 11
      And here is the code snippet where the rejection occurs...

      Code:
      if (order.Name == "Stop1")
      						{
      							isStop1Filled = order.OrderState.Equals(OrderState.Filled);
      							// submit a Trailing Stop
      							if (isStop1Filled && !isTrailingStop)
      							{
      								isTrailingStop = true;
      								Print("ClearOrders - Submit trailStop.Quantity: " + stopTarget.Quantity);
      								account.Submit(new[] { trailStop });
      							}
      						}

      Comment


        #4
        Submission rejected???

        Found the error. It is now working correctly.

        One last point: when the TrailStop is submitted, it leaves a Yellow marker on the Chart which persists after the trade is closed. How can this be avoided (since it cannot be removed from the Chart)?

        Thanks,
        Ron
        Attached Files

        Comment


          #5
          Hello Ron,

          There would be a red order line marker if Chart Trader is open and the order is working.

          If the order fills this would put an execution marker on the chart.

          Are you referring to the execution markers?


          Regarding the invalid price, I'm not seeing in the code that you are checking the order's stop price is at least 1 tick less than bid. Likely your price is an invalid price. Also, you should check that the new price of the order is a valid price, one line before order submission so that the price doesn't have time to change either.
          Last edited by NinjaTrader_ChelseaB; 02-08-2018, 04:28 PM.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Submission rejected???

            Hi Chelsea:

            Actually, the problem was with the CreateOrder(). See below

            Also, I've attached a pic of the markers/flags on the Chart that the TrailStop generates but cannot be removed.

            Code:
            								if (stopOrder.IsLong)
            								// CreateOrder(Instrument instrument, OrderAction action, OrderType orderType, OrderEntry orderEntry, 
            								//	TimeInForce timeInForce, int quantity, double limitPrice, double stopPrice, string oco, string name, DateTime gtd, CustomOrder customOrder)
            								//  See: https://ninjatrader.com/support/helpGuides/nt8/en-us/?onorderupdate.htm
            								{
            									stopTarget = account.CreateOrder(stopOrder.Instrument, OrderAction.Sell, OrderType.Limit, OrderEntry.Automated, TimeInForce.Day, 
            										stopTargetQty, stopOrder.StopPrice + stopTargetSpread, 0, "", "stopTarget", Core.Globals.MaxDate, null);
            									
            									trailStop = account.CreateOrder(stopOrder.Instrument, OrderAction.SellShort, OrderType.StopMarket, OrderEntry.Manual, TimeInForce.Day, 
            										stopTargetQty, 0, stopOrder.StopPrice - stopTargetSpread, "", "TrailStop", Core.Globals.MaxDate, null);
            								}
            								else if (stopOrder.IsShort)
            								{
            									stopTarget = account.CreateOrder(stopOrder.Instrument, OrderAction.Buy, OrderType.Limit, OrderEntry.Automated, TimeInForce.Day, 
            										stopTargetQty, stopOrder.StopPrice - stopTargetSpread, 0, "", "stopTarget", Core.Globals.MaxDate, null);
            									
            									trailStop = account.CreateOrder(stopOrder.Instrument, OrderAction.BuyToCover, OrderType.StopMarket, OrderEntry.Manual, TimeInForce.Day, 
            										stopTargetQty, 0, stopOrder.StopPrice + stopTargetSpread, "", "TrailStop", Core.Globals.MaxDate, null);
            								}
            Thanks,
            Ron
            Attached Files

            Comment


              #7
              Hello Ron,

              These orders are orange because they are stuck.

              This often happens when OCO is improperly used.

              Please send an email to platformsupport [at] ninjatrader [dot] com so that I may request your log and trace files so that I may read the OCO IDs used.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hi Chelsea:

                I've sent the requested files to support.

                Btw, I am not using OCO. I suspect these orders are "stuck" because they were in an Initialized state, and then ended in CancelPending state (it never reached the Cancel state when I cancelled all orders). This may be a bug in NT8.

                Also, I am 'requesting' that a Trail Stop method be added to the AddOn group of methods, similar to SetTrailStop(). One line of code to save numerous lines and hours of work. This seems a reasonable request since the code already exists in the Strategy area; simply port if over to the AddOn area.

                Thanks,
                Ron

                PS: problem resolved by not using CreateOrder() for the trailStop until Stop1 is triggered. At that point trailStop is also Submitted. See attached Strategy.
                Attached Files
                Last edited by ronhb107; 02-09-2018, 11:23 AM.

                Comment


                  #9
                  Hello ronhb107,

                  Thank you for your response.

                  I will forward your request to our development team for possible implementation in a future release.
                  Patrick H.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello ronhb107,

                    Thank you for your patience.

                    This request has been assigned the internal tracking id of SFT-3028.

                    Please let me know if you have any questions.
                    Patrick H.NinjaTrader Customer Service

                    Comment


                      #11
                      Order Rejected

                      This is a new problem, where an order is rejected and an OCO id is the cause.

                      Running Sim101, an ATM tried to place a Stop1 order but was rejected because it tried to reuse an OCO id; except, I did not use an OCO (I generally don't).

                      This is occurring under a Strategy which manages the manual order.

                      I have attached a pic of the Control Center > Log and also the Strategy.

                      Please let me know if you need other info.

                      Thanks,
                      Ron
                      Attached Files

                      Comment


                        #12
                        Hello ronhb107,

                        Thank you for your update on this matter.

                        I will review and follow up with you as soon as possible.
                        Patrick H.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello ronhb107,

                          Thank you for your patience.

                          I cannot reproduce the error or any behavior with the recent strategy you attached. Can you detail the steps needed to reproduce the behavior?

                          I look forward to your response.
                          Patrick H.NinjaTrader Customer Service

                          Comment


                            #14
                            Order Rejected

                            Patrick, I will try to reproduce this and get back to you if the problem persists.

                            My strategy code has changed since then.

                            Ron

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by kevinenergy, Today, 11:53 AM
                            0 responses
                            1 view
                            0 likes
                            Last Post kevinenergy  
                            Started by verge, Today, 11:36 AM
                            0 responses
                            2 views
                            0 likes
                            Last Post verge
                            by verge
                             
                            Started by Alfred, Today, 11:25 AM
                            0 responses
                            6 views
                            0 likes
                            Last Post Alfred
                            by Alfred
                             
                            Started by tradr, Today, 10:51 AM
                            3 responses
                            7 views
                            0 likes
                            Last Post NinjaTrader_Kate  
                            Started by slocumtrader, 02-08-2013, 10:51 AM
                            5 responses
                            1,836 views
                            0 likes
                            Last Post NinjaTrader_PatrickG  
                            Working...
                            X