Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

holding strategy overnight

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

    holding strategy overnight

    Let us assume I have a position (with corresponding stop) in my strategy that I want to keep overnight.

    What are the paramters needed to have sync this strategy to the position on the next trading day?

    What I have in mind:

    1. Use GTC for the stop order
    2. Set ExitOnClose=false for the strategy
    3. In Control Center->Options->strategies->NinjaScript->Order Handling
    disable Cancel Entry Orders when strategy disabled
    disable Cancel Exit Order when strategy disabled



    Does this yield the situation that the next morning the strategy will sync again to the open position held overnight?

    Question here: What is an exit order: Is the Stop loss order mentioned above considered an exit order?

    #2
    I am with IB and I just leave the strategy running overnight, and then no sync issue.

    In addition to your list because of disconnects and restarts and such like I set Strategies>Ninjascript Handling to KeepRunning

    I use the following in Initialize.

    ExitOnClose=false;
    TimeInForce=Cbi.TimeInForce.Gtc;
    MaxRestartAttempts=123;//Or some other number
    MaxRestartMinutes=123;//Or some other number
    RestartDelaySeconds=123;//Or some other number

    Comment


      #3
      Thank you,


      I assume that you close IB every day after 22 EST? You have to because IB will close by itself.


      Will the strategies also sync if you close NinjaTrader and start it back the next morning?

      Greetings to the other side of the world.
      Andreas

      Comment


        #4
        IB Lock & Exit

        Originally posted by zweistein View Post
        Thank you,

        I assume that you close IB every day after 22 EST? You have to because IB will close by itself.
        I try not to as I trade 24hr futures. I start IB at the beginning of the week. Then twice a day go to Configure>Global Configuration>Lock & Exit and change AM to PM (or vice versa) and click apply. It is next to impossible to change the time as the NT API polling snatches the cursor. I recall this was a NT 7 request from a number of users !

        Will the strategies also sync if you close NinjaTrader and start it back the next morning?
        I know NT development did some work on this, but they will need to advise current status.

        Likewise greetings to the other side of the world!
        Hugh

        Comment


          #5
          Andreas,

          When you stop your strategy, shutdown NT, etc. it will try to sync only based on your settings. First, when you started your strategy, be sure to set "Sync account position" to true. Then, depending on what you have checked in Tools>Options>Strategies>NinjaScript for "On starting a real-time strategy" determines the rest of the behavior.

          For your case I would think "Immediately submit" will fit your needs the best. It will try to match any working orders as determined by the strategy to any active orders in your account. Any mismatches of position will have reconciliation attempts via a market order of the difference.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            I didn't know it was the NT api that snatches the IB cursor, allthough the effect is well known to me and it is annoying (at least).

            THANK YOU, I have learned something new.

            So I also suggest to the NT team to review their IB api.

            Well, keeping IB open all week is not really an option to me, I would rather close NT and IB programmatically each day and relaunch again.


            TO the NT team:

            In a Strategy we have:

            bool ExitOnClose
            bool CancelEntryOnDisabled
            bool CancelExitOnDisabled.

            Setting these parameters in Initiallize() should work and yield the expected results.

            But...


            Can I set these parameters also from within OnBarUpdate()?

            especially:

            setting ExitOnClose within OnBarUpdate(), will this change the exitonclose beahviour?


            setting CancelEntryOnDisabled or CancelEntryOnDisabled in OnBarUpdate() ? Working?

            My common sense tells me that the check for CancelEtrnyOnDisabled is done only in the moment when the strategy is beeing disabled , be it because of sessionend or because of disconnect.

            Could you please confirm this beahviour?


            concering ExitOnClose: Here it would be nice to change this also in OnBarUpdate()
            To be able to do so you could just check for the value at the time ExitOnCloseSeconds_before_exit.

            Thank you for clarifications

            Andreas

            Comment


              #7
              We do not recommend dynamically changing those values.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Parameters

                Originally posted by zweistein View Post

                bool CancelEntryOnDisabled
                bool CancelExitOnDisabled.

                Setting these parameters in Initiallize() should work and yield the expected results.

                Andreas
                I am unable to set these bools in Iniatialize() in NT7B4

                Have you found a way to do this?

                Hugh

                Comment


                  #9
                  We will check into this.
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    I would like to specify better my needs:

                    A typical situation is that I start with a strategy for an intraday trade. Such a strategy would usually have an ExitOnClose=true and would exit the latest at SessionEnd-ExitOnCloseSeconds .


                    When I see during the day that the position is worth holding overnight I would be able to do so for the already running strategy.

                    So I would:
                    Options->Strategies->NinjaScript->OrderHandling
                    CancelEntryOnDisabled UNCHECKED
                    CancelExitOnDisabled UNCHECKED


                    In this way I can disable and reenable the strategy without changing the order status.

                    So I disable the strategy then,
                    then I set ExitOnClose=false
                    then I set TimeInForce to Gtc
                    the I reenable the strategy

                    Is it correct to assume tha the strategy will
                    A: Change any Day orders into Gtc Orders?
                    B: Continue running and not exit at the end of the day?
                    C: On Reopen Ninja the next day as soon as I enable the strategy again will it sync to any existing position?


                    Regards

                    Comment


                      #11
                      What you also need to know is that IB somehow reset their systems at around 6:45 AM CET.

                      The strategies keep running, but NT issues a warning message saying "Strategy xyz123 lost price connection but will keep running." When running many strategies simultaneously, this results in the need to "click away" around 50 of those messages every morning. Josh or Ray, is there a way to disable non-critical notification messages like this one?

                      zweistein: What if you set up a "counter-strategy? That is, if your long strategy exits at ExitOnClose - 123seconds, set up a second long strategy that goes long the same amount of contracts at ExitOnClose - 123seconds? You'd pay commissions twice, but you could be sure nothing can go wrong with undesired exits/entries...

                      Regards,
                      noincome

                      Comment


                        #12
                        My setup is:

                        7.50 CET Open NinjaTrader

                        22.05 CET Close NinjaTrader

                        every day.
                        I have a macro that does this automatically.

                        It can happen that I am not in front of the Trading Screen , that is why I use strategies, otherwise I could just trail my positions by hand.

                        I want to do the strategy do what I expect from it, reliably. Nothing else.

                        @noincomenojobnoassets: Usually I use counter postions in case of broker problems, then I put the opposite order in another account. Rather not if the volatility is very high. Thank you for your suggestion, but the point is that I do not want to sit in front of the PC at 22 CET!
                        Have a nice day
                        Andreas

                        Comment


                          #13
                          Oh, and just for the record: This key-snatching "feature" IS extremely annoying - would love to see a switch for this being included.

                          Comment


                            #14
                            Aussie2,

                            The property names are actually:
                            CancelExitOrdersOnDisable
                            CancelEntryOrdersOnDisable

                            zweistein,

                            Will get back to you.

                            noincomenojobnoassets,

                            Thank you for the suggestion.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              zweistein,

                              A. It will not change TIF for the orders. Some adapters may do some conversion, but this is based on adapter limitations and not strategy logic.
                              B. Since they are Day orders still, they may be cancelled.
                              C. It will sync provided you have the sync options to true. In the sync process it will try to match account positions to strategy positions. If it is unable to do so it will reconcile the differences against the account position.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by CarlTrading, 03-31-2026, 09:41 PM
                              1 response
                              47 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by CarlTrading, 04-01-2026, 02:41 AM
                              0 responses
                              23 views
                              0 likes
                              Last Post CarlTrading  
                              Started by CaptainJack, 03-31-2026, 11:44 PM
                              0 responses
                              33 views
                              1 like
                              Last Post CaptainJack  
                              Started by CarlTrading, 03-30-2026, 11:51 AM
                              0 responses
                              51 views
                              0 likes
                              Last Post CarlTrading  
                              Started by CarlTrading, 03-30-2026, 11:48 AM
                              0 responses
                              42 views
                              0 likes
                              Last Post CarlTrading  
                              Working...
                              X