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

Resubmitting order while rejected

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

    Resubmitting order while rejected

    Hello All!

    I'm working on strategy that trades lilmit orders only
    I trade on Binance with NinjaTools connector.

    Sometimes order placement action returns rejections. It is normal.
    I have to say that rejections are not because of wrong price or wrong order generally.
    Error code shows that rejection is usually because of high load on exchange.
    I've realized code within OnOrderUpdate section that should check if order rejected.
    If so it should resubmit it.
    But actually it seems not.

    Here my code in OnOrderUpdate section that should resubmit order if rejected:

    Code:
    if (order.Name == "long limit entry") {
            if (order.OrderState == OrderState.Rejected) {
                longentryOrder_0 = EnterLongLimit(0, true, lotage, limitprice, "long limit entry");
            }
    }
    Initial order sent in OnBarUpdate or OnExecutionUpdate Sections, depending on certain conditions.

    That I do in wrong way?
    Please assist

    Best Regards,
    Makhmut​

    P.S.

    Code:
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelCloseIgnoreRejects;
    Last edited by makhmout; 04-01-2023, 01:10 PM.

    #2
    Hello Makhmut,

    Thanks for your post.

    You could use RealtimeErrorHandling to determine the behavior of a strategy when the strategy places an order that is returned "Rejected". The default behavior is to stop the strategy, cancel any remaining working orders, and then close any open positions.

    By setting RealtimeErrorHandling to RealtimeErrorHandling.StopCancelCloseIgnoreRejects , the strategy will perform default behavior on all errors except order rejections.

    You could trap the rejected order by checking if the OrderState is Rejected within OnOrderUpdate() as you have shared followed by defining your own order rejection handling behavior for the rejected order.

    Please see the example in the help guide link below that demonstrates using RealtimeErrorHandling and trapping a rejected order in OnOrderUpdate().

    RealtimeErrorHandling — https://ninjatrader.com/es/support/h...orhandling.htm

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

    If the strategy is not behaving as expected, such as placing or not placing orders when expected, debugging prints should be added to the script to understand exactly how the script is behaving.

    ​Below is a link to a forum post that demonstrates how to use prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121

    Please let me know if I may assist further.​
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by geddyisodin, Today, 05:20 AM
    5 responses
    32 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by bmartz, Today, 09:30 AM
    2 responses
    12 views
    0 likes
    Last Post bltdavid  
    Started by f.saeidi, Today, 11:02 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by geotrades1, Today, 10:02 AM
    4 responses
    12 views
    0 likes
    Last Post geotrades1  
    Started by rajendrasubedi2023, Today, 09:50 AM
    3 responses
    16 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X