Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Closing strategy without closing pending orders or open position

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

    Closing strategy without closing pending orders or open position

    Hi,
    CloseStrategy(string) actually closing positions and cancelling pending orders, I have checked the help guide and also tried it. Can you please advise what syntax I should use to only disable the strategy without closing open positions and without canceling any pending order. Thanks in advance.

    #2
    Up this post....

    I also do not know this one.

    Last time, i just close it manually then only do not close the pending order.



    But i think shouldn't close strategy is there is still pending order.

    Comment


      #3
      Hello asmmbillah,

      You can use SetState(State.Terminated) to disable the strategy without the CloseStrategy actions which will "Cancels all working orders, closes any existing positions, and finally disables the strategy".
      https://ninjatrader.com/support/help...8/setstate.htm
      https://ninjatrader.com/support/help...sestrategy.htm
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        thanks, that solves the problem.

        Comment


          #5
          Hi CheseaB,

          The problem I face now is, I have open position, pending orders on the account. When I enable the strategy, it cancels all the pending orders keeping the position open. Is there anyway I can enable the strategy without cancelling any pending order?
          Last edited by asmmbillah; 01-25-2021, 06:47 AM.

          Comment


            #6
            Hello asmmbillah,

            This would only be possible if in the historical data the orders match with the previously submitted real-time orders and the Immediately Submit start behavior is used. A match means the order type, signal name, submission and fill time, and quantity must match. Otherwise the strategy would not match the order and automatically cancel it.

            https://ninjatrader.com/support/foru...182#post783182
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks, I have tried immediate submit and immediate submit synch account position options according to your post link and contents there. Nothings works. In both the occassions, it cancels the pending orders when I re-enable the strategy. Please advise.

              Comment


                #8
                Hello,

                May I confirm that the orders are submitted to a 1-tick series as directed in the forum post I have linked?

                Are the order names, prices, submission and fill times all the same?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  It places orders on BarsInProgress == 0; Do you want me to add AddDataSeries() for 1 tick and execute pending orders on BarsInProgress == 1?

                  Comment


                    #10
                    Hello asmmbillah,

                    That would depend on the type of orders and if the position is the same at the same time and if the orders are being submitted at the same price and time.

                    If the orders do not match, they cannot be resumed.
                    If the time or price is different, the orders will be automatically cancelled.

                    You can use TraceOrders and Print() to print the order object in OnOrderUpdate() and verify the order prices and times are the same from the real-time, and then with the historical after being reloaded.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks for your reply. Pending entry orders are generated with click of custom button, but SL and PT pending orders are generated with entry order onexecutionupdate. In that case, it will not match as the start of the process is started with click of a button. What is your advised in this case so that I can re-enable and keep the pending orders?

                      Comment


                        #12
                        Hello asmmbillah,

                        Orders that are generated from button clicks will not be submitted in historical data, will not be matched, and will automatically be cancelled.

                        Perhaps you would prefer to use an addon or indicator with the addon approach to send orders instead of an automated strategy?

                        You could try writing the order information to a text file, reading this from text file in historical data, and submitting the order historically at the same time and price.
                        https://ninjatrader.com/support/help...o_write_to.htm
                        https://ninjatrader.com/support/help...o_read_fro.htm
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks. I think read write may be suitable. But question is, if the strategy is disabled, I want to write the pending orders. Should I write in state=state.terminated ? and how I can access pending order within orders to write them in file?

                          Comment


                            #14
                            Hello asmmbillah,

                            State.Terminated would be correct.

                            You can add the orders to an array or list and loop through them.

                            Check the OrderStates of the orders.
                            https://ninjatrader.com/support/help.../nt8/order.htm
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Thanks and will it be true even for live account where normally working and accepted orders resides within broker's server? are those also get cancelled similar which we discussed in post #11?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by AaronKoRn, Today, 03:05 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Emily  
                              Started by zacharydw00, Today, 02:21 PM
                              2 responses
                              15 views
                              0 likes
                              Last Post zacharydw00  
                              Started by Harvard, Today, 12:01 PM
                              2 responses
                              13 views
                              0 likes
                              Last Post Harvard
                              by Harvard
                               
                              Started by DanDaMan, Today, 12:40 PM
                              5 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_Zachary  
                              Started by bob999, 02-16-2021, 10:00 AM
                              3 responses
                              29 views
                              0 likes
                              Last Post NinjaTrader_Kate  
                              Working...
                              X