Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error Unable to Change Order

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

    Error Unable to Change Order

    Hello,

    I am getting the following error. I know the meaning of it.

    Click image for larger version

Name:	Error .png
Views:	25
Size:	18.1 KB
ID:	1130868

    The error disables the strategy. Is there any way to just close open positions, cancel open orders and just continue with operations. Instead of having to enable the strategy again?

    I tried the "RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors" but it seens it does not work. The code is:

    (State == State.Configure)
    {

    //RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;

    }


    SetStopLoss("SE11", CalculationMode.Price, High[1] + (Order01SL * TickSize), false);


    protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
    {
    if (order.Name == "Stop loss" && orderState == OrderState.Filled)
    Stop = order;

    if ("Stop loss" != null && Stop == order)
    {
    // Rejection handling
    if (order.OrderState == OrderState.Rejected)
    {
    // Stop loss order was rejected !!!!
    // Do something about it here
    CancelOpenEntries();
    CancelOpenOrders();
    }
    }
    }
    Attached Files

    #2
    you're asking to close an order, but there wasn't on initiated, so you'll get an error. Cancellation should occur only if orderState == OrderState.Filled

    right now you are only checking if it's rejected - so there is no order initiated. There is nothing to cancel.

    if (order.OrderState == OrderState.Rejected)
    {
    // Stop loss order was rejected !!!!
    // Do something about it here
    CancelOpenEntries();
    CancelOpenOrders();

    Comment


      #3
      Hello Jorge.andres.o,

      With the Unable to change order message, this can happen for a few reasons.
      The order may not be in a working state when the order modification is submitted or when it is received by the broker. For example if at the exact moment the price of an order is attempted to be modified and that order is filled or cancelled on the brokerage servers, the brokerage would send this order error message back saying they cannot modify the price of an order that is not in a working state.
      These orders can also occur if the order is changed to an invalid price or if the order is attempted to be modified but the brokerage is not able to change the order because the amount of funds in the account or other brokerage side factors.
      The message itself is saying that the order could not be modified. That order may actually still be working or may have filled or may have been cancelled. It might not be rejected.

      The RealtimeErrorHandling.IgnoreAllErrors would allow the strategy to continue running and not be disabled, however, with the two slashes at the beginning of the line this makes it a comment that is not actually evaluated as code. Remove the two slashes at the beginning of the line, compile, add a new instance of the strategy.

      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by toughiee, Today, 12:04 AM
      0 responses
      2 views
      0 likes
      Last Post toughiee  
      Started by vdoan20, Yesterday, 08:30 PM
      0 responses
      6 views
      0 likes
      Last Post vdoan20
      by vdoan20
       
      Started by gupagoer, Yesterday, 07:42 PM
      0 responses
      9 views
      0 likes
      Last Post gupagoer  
      Started by Holligoly, Yesterday, 05:13 PM
      2 responses
      11 views
      0 likes
      Last Post Holligoly  
      Started by Raginpower, Yesterday, 01:53 PM
      0 responses
      14 views
      0 likes
      Last Post Raginpower  
      Working...
      X