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

Strategy sent cancel request

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

    Strategy sent cancel request

    Hi, Occasionally I get this error in my strategy when placing a trade. Happens when the market is moving fast. Is there a way to capture this error so the strategy doesn't terminate? thanks



    Strategy 'MyNT8TradeEntry/200702403' submitted an order that generated the following error 'Order rejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.

    Sim101, Sell stop or sell stop limit orders can't be placed above the market. affected Order: Sell 1 StopLimit @ 2833 x 2833


    Order='7ac9483809b44823940a9d11589b013f/Sim101' Name='shortOrder3' New state='Rejected' Instrument='ES 06-20' Action='Sell' Limit price=2833 Stop price=2833 Quantity=1 Type='Stop Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='Order rejected' Native error='Sell stop or sell stop limit orders can't be placed above the market.'
    Attached Files

    #2
    Hello pman777,

    Thanks for your post.

    To prevent the strategy from being deactivated, you can set the strategy's RealtimeErrorHandling property to IgnoreAllErrors or StopCancelCloseIgnoreRejects. With this property set, you can then trap order rejections in OnOrderUpdate if you would like to have the strategy attempt a different action.

    RealtimeErrorHandling - https://ninjatrader.com/support/help...orhandling.htm

    OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm

    Please let me know if I can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      thank you Jim. Can you provide a sample or example where an error is captured in OnOrderUpdate()?

      Comment


        #4
        Hello pman777,

        You could consider the following as an example for a handling a rejection on a stop loss order submitted with SetStopLoss(). Order.Name would be the signal name given when submitting the order.

        Code:
        protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice, 
            int quantity, int filled, double averageFillPrice, 
            Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment)
        {
            if (order.Name == "Stop loss" && order.OrderState == OrderState.Rejected)
                ExitLong();
        }
        We look forward to assisting.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rayyyu12, Today, 05:38 PM
        0 responses
        2 views
        0 likes
        Last Post rayyyu12  
        Started by xepher101, Yesterday, 12:19 PM
        2 responses
        28 views
        0 likes
        Last Post xepher101  
        Started by thumper57, Today, 04:30 PM
        0 responses
        4 views
        0 likes
        Last Post thumper57  
        Started by OllieFeraher, 05-09-2024, 11:14 AM
        5 responses
        16 views
        0 likes
        Last Post MisterTee  
        Started by jackiegils, Yesterday, 11:05 PM
        1 response
        11 views
        0 likes
        Last Post marcus2300  
        Working...
        X