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

Rejected Order - Submission vs Execution

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

    Rejected Order - Submission vs Execution

    Hi there,

    I need some guidance with handling rejected orders. Sometimes orders get rejected when you submit them e.g. a StopMarket order that's on the wrong side of price. And sometimes orders get rejected when they get hit. For example a Forex order, which gets hit but can't fill due to insufficient margin.

    How can I differentiate between these two different order rejection scenarios?

    Thanks

    Kevin.

    #2
    Hello kevinenergy,

    Thank you for your post.

    RealtimeErrorHanlding is set in OnStateChange under State.SetDefaults. You can set this to RealtimeErrorHandling.StopCancelCloseIgnoreRejects , and the strategy will stay running when a rejection is encountered.

    You can check for an order that is rejected in OnOrderUpdate by checking if (order.OrderState == OrderState.Rejected).

    When a rejected order is detected, you can also check the ErrorCode string, and see if it contains the string you see for that particular rejection reason.

    If you see a rejected order and you see the specific error message for that order type, you have determined the rejection that was received was the order being on the wrong side of the price or insufficient margin.

    If you see a rejected order and the message contains a specific message like that, you can treat it like any other rejection that would previously disable the strategy and invoke the Stop Cancel Close behavior by calling CloseStrategy(), or you could choose to resubmit the order if it's a stop rejection or close the position.

    CloseStrategy() — https://ninjatrader.com/support/help...sestrategy.htm

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mgco4you, Today, 09:46 PM
    1 response
    2 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by wzgy0920, Today, 09:53 PM
    0 responses
    3 views
    0 likes
    Last Post wzgy0920  
    Started by Rapine Heihei, Today, 08:19 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by Rapine Heihei, Today, 08:25 PM
    0 responses
    6 views
    0 likes
    Last Post Rapine Heihei  
    Started by f.saeidi, Today, 08:01 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X