Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Keep Strategy Running

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

    Keep Strategy Running

    I want to keep my strategy running after EndSession so it will start the next day without intervention from me. I also want to make sure any open position is closed prior to EndSession. I am assuming the correct way to do this is to:

    1. Set ExitOnClose to false.
    2. Write my own routine to close open positions a few seconds prior to EndSession.

    Reading the Docs for ExitOnClose I found this:
    Indicates if the strategy will cancel all strategy generated orders and close all open strategy positions at the close of the session.

    It does not state it will shut down the strategy, but I assume this is what’s happening?
    Thanks,

    -Scott

    #2
    ExitOnClose will halt your strategy. The tough part will be though to get it restarted next days morning open. I would not see right now how you could achieve that.

    Comment


      #3
      Dierk,

      So, if I set ExitOnClose to false, what exactly will happen? I would think the strategy would remain loaded after EndSession and any open position would stay open after EndSession. This would allow my strategy to run and start taking new order the next morning - as soon as current time was greater than BeginSession.

      Maybe I'm just missing what ExitOnClose does??

      Thanks,

      -Scott

      Comment


        #4

        Comment


          #5
          Thanks Dierk, but since my original post contained a quote from this exact page you just linked, I think it's pretty clear that I've read the material.

          I don't think I can make my question any clearer. I'll work on it myself and report back my findings, as I am sure it will be helpful to others as well.

          -Scott

          Comment


            #6
            CashCache your approach should work fine. ExitOnClose will halt your strategy so you will need to restart your strategy if you decide to go that route. Since that doesn't seem to be what you want to do you will need to build your own routine. Hope that makes sense.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Josh,

              That's what I suspected but was looking for some clarification. I'm working on a routine that will make sure I am flat by the time EndSession is reached.

              Thank you for clarifying that for me.

              -Scott

              Comment


                #8
                Also: as of now the strategy will be terminated due to the ExitOnClose handling. This will be changed with next NT6.5 beta: the strategy will kept running. We will clarify that in the docs.

                Comment


                  #9
                  This topic interests me also. I am using version 6.5 and the session end seems to halt the strategy again. Halted strategy cannot be simply run again by pressing Start (why the Start is in the strategies tab after the strategy is stopped I do not understand) but a new instance must be created, which is quite annoying to do every day and fill the strategy parameters over and over.

                  Please advice, what are the options if the strategy uses e.g. 30 minute bars, but I want to make sure 30 seconds before session ends the strategy position is flat BUT the strategy keeps active.
                  Setting ExitOnClose=True does not do the job, because it halts the strategy
                  Setting ExitOnClose=False also does not do the job, because OnBarUpdate() runs every 30 minutes and cannot not go flat 30 seconds before session ends.

                  Is the only way to set the strategy to tick-by-tick processing, ignore all ticks between 15 minute intervals and go flat 30 seconds by script (ExitOnClose=False)?
                  It seems ExitOnClose does something more that is expected than "Order Handling", it should be clearly split between exiting positions (=going flat) and halting a strategy.

                  Thanks.

                  Comment


                    #10
                    kornel,

                    Please ensure you are on the latest version of NinjaTrader 6.5.1000.6. The ExitOnClose behavior does not terminate your strategy anymore. It simply closes out your position and continues to run after that.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Josh,

                      thanks for quick response. I upgraded from 6.5.1000.4 to 6.5.1000.6 to check it.
                      The same happened again:
                      - the session end was set to 16:15
                      - ExitOnClose=True
                      - Exit on close seconds=30
                      16:14:30 the strategy stopped and pressing Start does not start it (obvious reason: "you cannot start strategy which is terminated").

                      I would just add that:
                      - I am not programatically halting the strategy
                      - the language used is internal NinjaScript/C# (not external using dll)
                      - the strategy did one trade this day and was flat since 16:02

                      What is quite strange, when I opened another strategy instance afterwards and set the session end to 16:45 and started the strategy with the same parameters (ExitOnClose=true and exit on close 30 seconds) the strategy keeps running, probably until tomorrow when it will make at least one trade and halts again.

                      Could there be a bug that if there is long/short position established it behaves as you wrote, but if the strategy is flat but made a trade that day it halts?

                      Thanks for support.

                      Comment


                        #12
                        Hi kornel,

                        On my end I am unable to get it to halt the strategy at all. If you continue to experience this please let us know when you get a reproducible scenario. Thanks.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi Josh,

                          I tried to figure out why and found out you were right. It was not stopped by ExitOnClose but another feature. In Options was set "Flatten positions, Time to flatten=16:14:30, Flatten all=yes". I need to set this to eliminate risk and quit manually opened positions on other instruments, if anything happens.

                          My opinion is that this behaviour is unexpected and generally not desired. In ExitOnClose you corrected it, which I highly appreciate, please could you analyse and split the connection between flattening position and halting a strategy also on this place?

                          Otherwise there are only two options, one annoying and second one risky. Either to set Flatten all=yes and restart the strategy every day (regardless already fixed issue in ExitOnClose), or set Flatten all=no and risk that manually opened positions will not be closed before market closes and turn into overnight trades.

                          Since this is undocumented feature which is quite critical, could you please document all actions and settings that halt strategies? If it is documented somewhere please forgive my ignorance and point me to the place, I could not find it.

                          Thanks for support, you guys do a very good job.

                          Comment


                            #14
                            Hi kornel,

                            Thank you for the suggestion. I will forward it to development.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Thanks Josh

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              637 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              366 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              107 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              569 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              571 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X