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

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".

      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, 07: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.

            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.

                        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.
                            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 bill2023, Yesterday, 08:51 AM
                              8 responses
                              43 views
                              0 likes
                              Last Post bill2023  
                              Started by yertle, Today, 08:38 AM
                              6 responses
                              25 views
                              0 likes
                              Last Post ryjoga
                              by ryjoga
                               
                              Started by algospoke, Yesterday, 06:40 PM
                              2 responses
                              24 views
                              0 likes
                              Last Post algospoke  
                              Started by ghoul, Today, 06:02 PM
                              3 responses
                              16 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              46 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X