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

Order re-submit logic

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

    Order re-submit logic

    Hello guys,

    I would like to ask for your help/opinion about the following question.

    Is it a best practice to re-submit recursively an order that, for some reason, is not filled?

    For sure, I have to undestand why the order has not been filled. After that, are there some other factors that I have to know?

    Thanks.

    #2
    Hello,
    If an order is not filled then there would not be a reason to re-submit the order, unless the order was rejected or cancelled.
    You could check the order state of the order in the OnBarUpdate() method. For example:
    Code:
    protected override void OnOrderUpdate()
    {
        If(order.OrderState == OrderState.Rejected)
        {
            //DO Something
        }
        If(order.OrderState == OrderState.Cancelled)
        {
            //DO Something
        }
    }
    For more information on the OnOrderUpdate() method please see the following link: https://ninjatrader.com/support/help...rderupdate.htm

    For more information on creating your own rejection handling please see the following link: https://ninjatrader.com/support/help...orhandling.htm

    To really comment on the best way to resubmit the order I will need to know more about the scenario.
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the answer CodyB.

      It's not clear to me what do you mean with:

      Originally posted by NinjaTrader_CodyB View Post
      If an order is not filled then there would not be a reason to re-submit the order
      If I'm placing a limit order and it's not filled, I have to resubmit the limit order because my strategy expect that a limit order is filled. Do you agree?

      Originally posted by NinjaTrader_CodyB View Post
      To really comment on the best way to resubmit the order I will need to know more about the scenario.
      Basically, my aim is to handle all the possible errors that could occurs during the strategy execution and to assure that all the orders generated by the strategy are filled. It depends on the type of error, I know, but my idea is to try to resubmit recursively an order for at maximum a number of attempts defined by the strategy.

      Thanks

      Comment


        #4
        Hello,
        Can you please clarify the situations where you are expecting that you would need to resubmit an order? Are you expecting a rejection message? Otherwise the limit order would just remain pending and would still exist.

        You could use OnOrderUpdate for checking on orders and then submit a new order if there is a rejection message, ,and use a for loop to handle the number of times to resubmit the order, if this is how you want to handle rejections please see the following link on rejection handling: https://ninjatrader.com/support/help...orhandling.htm ,and the following link on looping commands: https://ninjatrader.com/support/help...g_commands.htm
        Cody B.NinjaTrader Customer Service

        Comment


          #5
          Yes,

          I expect a rejection message or a cancelled message. If I understood correctly, they are the only 2 cases for which I have to resubmit an order.

          Thanks for the help.

          Comment


            #6
            Hello,
            Yes this would be the case.
            You can handle this within the OnOrderUpdate() method and check the order state and then enter in your own handling methods.
            Code:
            protected override void OnOrderUpdate(IOrder order)
            {
                if(order.OrderState == OrderState.Rejected)
                {
                   //Order was rejected
                   //Do something about it here
                }
                if(order.OrderState == OrderState.Cancelled)
                {
                    //Order was Cancelled
                    //Do something about it here
                }
            }
            An option to have the limit order not cancel out would be to submit the order using Advanced Order Handling with LiveUntilCancelled set to true. Please see the following link on the LiveUntilCancelled order property: https://ninjatrader.com/support/help...r_handling.htm

            For submitting the order a certain number of times I would recommend to put enter your order method into a for loop within your order handling. A for loop will loop through submitting the order for a certain number of times that you can set.
            Please see the following link on our documentation for OnOrderUpdate(): https://ninjatrader.com/support/help...rderupdate.htm

            Please see the following link on our documentation for RealTimeErrorHandling:

            Please see the following link on our documentation for the various looping commands:https://ninjatrader.com/support/help...g_commands.htm
            Cody B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by mbk2787 View Post
              Hello guys,

              I would like to ask for your help/opinion about the following question.

              Is it a best practice to re-submit recursively an order that, for some reason, is not filled?

              For sure, I have to undestand why the order has not been filled. After that, are there some other factors that I have to know?

              Thanks.
              Regardless your strategy is day trading or positional, in my experience, you'll never know if a trade is going to be a successful one that you can't afford to miss. Your strategy should keep alive an order while the signal ( accordingly ) is still current. Here is where you have to exam market conditions, liquidity, spread and others variable to decide if submit limit or market orders. That procedure can be written into a script of course, but the hard part is what is your experience in this and how to code it efficiently.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by wzgy0920, Yesterday, 09:53 PM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by Rapine Heihei, Yesterday, 07:51 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by kaywai, Today, 06:26 AM
              1 response
              6 views
              0 likes
              Last Post kaywai
              by kaywai
               
              Started by ct, 05-07-2023, 12:31 PM
              6 responses
              206 views
              0 likes
              Last Post wisconsinpat  
              Started by kevinenergy, 02-17-2023, 12:42 PM
              118 responses
              2,780 views
              1 like
              Last Post kevinenergy  
              Working...
              X