Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit at close and enter at open

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

    Exit at close and enter at open

    In backtest, I would like to implement the following algorithm intraday. If position is open, it should be exited at session close (for that I set ExitOnClose = true). Based on some conditions, I may need to enter new position on the next session open. However, that order seems to be cancelled when ExitOnClose = true. Is there a workaround for that?

    #2
    Andy_Mil, welcome to our support forums!

    I would suggest then not using the 'ExitOnClose' feature, but closing your open position then by adding a time filter rule - http://www.ninjatrader-support2.com/...ead.php?t=3226

    This should then not cancel any additionally placed / parked orders.

    Comment


      #3
      Thanks for your reply, Bertrand. As far as I could see, using time filter will not allow me to exit the position at the session close. Setting ExitOnClose seems to be the only way to accomplish that. Am I right?

      Comment


        #4
        Andy_Mil, thanks for the reply - the same exit can accomplished by working with Time directly, for example this snippet would exit all open position by 1545 -

        Code:
         
        if (ToTime(Time[0]) >= 154500)
        {
        ExitShort();
        ExitLong();
        }
        The ExitOnClose just picks up the entered Session times in the Chart Properties.

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Andy_Mil, thanks for the reply - the same exit can accomplished by working with Time directly, for example this snippet would exit all open position by 1545 -

          Code:
           
          if (ToTime(Time[0]) >= 154500)
          {
          ExitShort();
          ExitLong();
          }
          The ExitOnClose just picks up the entered Session times in the Chart Properties.
          That is not entirely correct. ExitOnClose forces the exit at the close price of the last bar in the session (which is what often needed for intraday stock strategies). Whereas ExitShort() and ExitLong() place the market exit order at the open of the next bar (in case of stocks it will be next day open and price can be quite different from the last day close)
          I can see as the workaround placing exit order at the open of the last minute bar (at 15:59) but was looking for more elegant solution...

          Comment


            #6
            Andy_Mil, unfortunately I'm not aware of another workaround.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            627 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            359 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            562 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            567 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X