Announcement

Collapse
No announcement yet.

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.​
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    46 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    66 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X