Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	192
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 alifarahani, Today, 09:40 AM
      6 responses
      36 views
      0 likes
      Last Post alifarahani  
      Started by Waxavi, Today, 02:10 AM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by Kaledus, Today, 01:29 PM
      5 responses
      14 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by Waxavi, Today, 02:00 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by gentlebenthebear, Today, 01:30 AM
      3 responses
      17 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X