Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

unable to cancel

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

    unable to cancel

    Hello, Im having this "unable to cancel" error, only on real account (because of the latency):

    On bar update this line moves the stop
    SetStopLoss(@"entryOrderShort",CalculationMode.Pri ce, stopLossLevel,false);


    the stoploss moves and receives this error: (unable to change)

    2021-10-01 09:35:49:820|1|32|Order='1592082970/208241' Name='Stop loss' New state='Working' Instrument='NQ 12-21' Action='Buy to cover' Limit price=0 Stop price=14692 Quantity=1 Type='Stop Market' Time in force=GTC Oco='501326807552' Filled=0 Fill price=0 Error='Unable to change order' Native error='Buy order stop price must be above last trade price ExchangeRejectCode = 2061'


    So this line comes into play


    if(order.Name == "Stop loss" && error == ErrorCode.UnableToChangeOrder)
    {
    ExitLong(order.FromEntrySignal);
    ExitShort(order.FromEntrySignal);
    }

    It got filled

    2021-10-01 09:35:49:963|1|32|Order='1592044797/208241' Name='Buy to cover' New state='Filled' Instrument='NQ 12-21' Action='Buy to cover' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=1 Fill price=14566 Error='No error' Native error=''


    Immediately after this error occurs: (unable to cancel order)


    2021-10-01 09:35:49:978|1|32|Order='1592082970/208241' Name='Stop loss' New state='Working' Instrument='NQ 12-21' Action='Buy to cover' Limit price=0 Stop price=14692 Quantity=1 Type='Stop Market' Time in force=GTC Oco='501326807552' Filled=0 Fill price=0 Error='Unable to cancel order' Native error='Buy order stop price must be above last trade price ExchangeRejectCode = 2061'


    Maybe it is necessary to cancel the stop before sending the exitshort ()?

    How can I get this error on replay?

    Thanks in advance. Log on the attachments




    Last edited by NinjaTrader_Jim; 10-13-2021, 12:43 PM.

    #2
    Hello rocker84,

    Thanks for your post.

    We have removed your log file from the forum so others are not able to access information like your account number.

    If you need to send in log and trace files, we recommend sending them to platformsupport [at] ninjatrader [dot] com for technical support inquiries, or to scriptingsupport [at] ninjatrader [dot] com if the matter involves a NinjaScript you are developing.

    The log file is saved internally in our ticketing system, so there is no need to send it in again.

    Exit methods of the Managed Approach will cause cancels to be sent on existing orders if the strategy position gets flattened by the Exit order.

    It is possible where a cancel is sent for a Stop Loss order, but the Stop Loss fills before the cancel can be received and processed. Handling that scenario can be done by first canceling the order, listening for the cancelation in OnOrderUpdate, and then closing the position with an Exit method once the order is confirmed to be cancelled.

    SampleCancelOrder - https://ninjatrader.com/support/help...thod_to_ca.htm

    Please note that CancelOrder cannot be used on stop loss/profit target orders submitted with Set methods. (You can use Exit methods for the target and stop, please see the example below)

    SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

    It is also possible that an active order is in the the process or filling or cancelling where you receive an order error when attempting to change or cancel the order. In this case, your order did cancel just after the UnableToCancelOrder error was seen.

    Cancelling orders before closing the position can be less impactful than an inflight scenario situation where one order fills before the cancel is seen and processed, so it can be a good move to try and cancel the orders before performing a hard exit.

    Let us know if you have any additional questions.

    Comment


      #3
      Originally posted by NinjaTrader_Jim View Post
      Hello rocker84,

      Thanks for your post.

      We have removed your log file from the forum so others are not able to access information like your account number.

      If you need to send in log and trace files, we recommend sending them to platformsupport [at] ninjatrader [dot] com for technical support inquiries, or to scriptingsupport [at] ninjatrader [dot] com if the matter involves a NinjaScript you are developing.

      The log file is saved internally in our ticketing system, so there is no need to send it in again.

      Exit methods of the Managed Approach will cause cancels to be sent on existing orders if the strategy position gets flattened by the Exit order.

      It is possible where a cancel is sent for a Stop Loss order, but the Stop Loss fills before the cancel can be received and processed. Handling that scenario can be done by first canceling the order, listening for the cancelation in OnOrderUpdate, and then closing the position with an Exit method once the order is confirmed to be cancelled.

      SampleCancelOrder - https://ninjatrader.com/support/help...thod_to_ca.htm

      Please note that CancelOrder cannot be used on stop loss/profit target orders submitted with Set methods. (You can use Exit methods for the target and stop, please see the example below)

      SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

      It is also possible that an active order is in the the process or filling or cancelling where you receive an order error when attempting to change or cancel the order. In this case, your order did cancel just after the UnableToCancelOrder error was seen.

      Cancelling orders before closing the position can be less impactful than an inflight scenario situation where one order fills before the cancel is seen and processed, so it can be a good move to try and cancel the orders before performing a hard exit.

      Let us know if you have any additional questions.
      thank a lot, tell me if I understood correctly.

      The stop change is generated with SetStopLoss

      The price is wrong so it generates ExitShort, and after it gets the Filled it cancels the stop. Don't cancel the stop sooner?

      Really reading the log I can't understand what exactly is causing the problem.

      Comment


        #4
        Hello rocker84,

        We can't confirm through the logs what method had changed your stop price order, or any logical decisions made from a NinjaScript.

        We can note that a change was attempted on the stop loss, we see an Unable To Change Order error, a Buy To Cover Market order was placed and filled after that, cancels were submitted and the stop loss cancelled appropriately. This adds up with the programmed behavior you are describing.

        There was not any inflight execution problem here (an inflight execution would be for example, if the stop loss filled before the cancel was received and processed.)

        Canceling an order before performing a hard exit would be good practice, but it does not look like it had hurt you in this situation.

        Sending in the full log and trace files to us over email allows us to give a more through review, where we can reference the log files and give a play-by-play for what had happened. Please keep this in mind for any future order submission questions that you would like our insight on.
        Last edited by NinjaTrader_Jim; 10-13-2021, 02:02 PM.

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello rocker84,

          We can't confirm through the logs what method had changed your stop price order, or any logical decisions made from a NinjaScript.

          We can note that a change was attempted on the stop loss, we see an Unable To Change Order error, a Buy To Cover Market order was placed and filled after that, cancels were submitted and the stop loss cancelled appropriately. This adds up with the programmed behavior you are describing.

          There was not any inflight execution problem here (an inflight execution would be for example, if the stop loss filled before the cancel was received and processed.)

          Canceling an order before performing a hard exit would be good practice, but it does not look like it had hurt you in this situation.

          Sending in the full log and trace files to us over email allows us to give a more through review, where we can reference the log files and give a play-by-play for what had happened. Please keep this in mind for any future order submission questions that you would like our insight on.
          ok thanks Jim, I sent those to scriptingsupport email

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          44 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          125 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          65 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X