Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem With "Exit on Session Close" - Strategy Backtest vs Live

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

    Problem With "Exit on Session Close" - Strategy Backtest vs Live

    When I run backtests for NQ in the strategy backtester, and check the box for Exit on Session Close, it exits any open trades at 4pm CST. This makes sense and is completely expected, as this is the end of the futures trading session.

    When I run the same exact strategy live on NQ, and check the box for Exit on Session Close, it consistently exits any open trades at 11pm CST. Please help correct this behavior, so that live strategies exit on the actual session close and not at 11pm each night.

    Additional Context:
    • In the strategy backtester, Trading Hours is set to <Use Instrument Settings>
    • The native NQ instrument (Tools > Instrumemts > NQ) Trading Hours is set to "CME US Index Futures ETH"
    • My Ninjatrader platform time zone is correctly set to Central Time (US & Canada)
    It's important that the live strategy exits at the correct time, before the actual session closes at 4pm, and not randomly at 11pm.

    #2
    Hello beejinator,

    Common confusion with the exit on close, is that the strategy can place new orders after the exit on close event.

    Below is a link to a forum post that demonstrates the exit on close does work, and has an example script of how to prevent new entries until the next session.
    NinjaTrader Community, A common inquiry is that the Exit on close didn't work in a NinjaScript Strategy because there is a position after the exit on close should have occurred. When viewing the log we often find that the Exit on close does indeed exit the position shortly before the end of the session (based on the Exit on
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Appreciate the quick response! However, that is not my issue - I am not experiencing new entries after the session re-opens. My problem is different: Exit on Session Close, when checked, doesn't do anything at all at the 4pm CST session close, but instead closes the position at 11pm CST. This only happens in live trading. When I use the strategy backtester, it shows trades being exited at the actual session close at 4pm CST.

      Example:
      If my strategy enters a position at 3pm CST, the system behavior I am experiencing is that NOTHING happens at 4pm CST when the session closes. The position will stay open until 11pm CST, where it closes with the label text "Exit on session close". Since 11pm is not a session close for NQ, this makes no sense to me.

      Comment


        #4
        Hello beejinator,

        The exit on close event will happen the number of ExitOnSessionCloseSeconds before the session end time defined in the Trading hours template selected in the Data Series window.
        This is what the video in the forum post is demonstrating.

        Please check your Trading hours template selected, and your PC time zone.

        You can change the session end time in the Trading hours template and get the exit on close to go off when you want as a test.
        Please try the exact steps shown in the video and let me know if you are getting different behavior.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi again,

          I'm sorry but it feels like you aren't hearing me / understanding what I'm saying. I am running a strategy on the NQ. This instrument's trading hours is set to CME US Index Futures ETH. The Trading Hours of this template are correct in Ninjatrader, and correctly show the session close time of 4pm CST for all weekdays. My computer's clock (obviously) is in the correct time zone. When Ninjatrader STRATEGY BACKTESTER runs the strategy, it exits on the correct session close (4pm CST). When Ninjatrader runs the LIVE STRATEGY, it inexplicably thinks that the end of the session is 11pm CST. This is 7 hours later than the actual session close at 4pm.

          The links you sent are related to a completely different issue that I am not experiencing. All I want is for the strategy to stop thinking the end of the session is 11pm, when all the settings in the system are telling it the end of session is 4pm.

          Comment


            #6
            I do see now that you mentioned the Data Series window, which I had not been looking at before. I believe this might fix the issue, as my trading hours template in the Data Series window was 24 x 7, instead of just inheriting the instrument that had been added to the chart. Thank you for that!! I have modified this in the data series window, and will see if that fixes the issue next time I have a trade on at the end of the session.

            Comment


              #7
              Hello beejinator,

              Are you certain you do not have the Tools -> Options -> Trading -> 'Auto close position' enabled?

              I am not able to reproduce this behavior.

              Below is a link to a video of testing the test script on the NQ 06-23 on the Playback connection in Central Daylight Time.
              https://drive.google.com/file/d/1HXz...w?usp=drivesdk

              Notice the exit on close occurs at 4:00 PM (1600) and the position is closed and the working order cancelled.
              Further there is no exit on close at 11:00 PM and the position and working order stays open through 11:00:15.

              The links you sent are related to a completely different issue that I am not experiencing.
              The link to the forum post is how to test the Exit on session close with the session end time specified in the Trading hours template.

              My understanding was that you feel that the Exit on session close is not occurring at the end time specified in the Trading hours template.

              To confirm, I am incorrect and your inquiry is not about the Exit on session close event?

              If this is not about Exit on session close that is discussed in the forum post with test scripts and a video, can you further clarify the specific issue you are having?


              If the behavior is about the Exit on session close, can you provide a video demonstration using the test script I have provided you, that follows the steps shown in the video demonstrating the exit on session close?
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              89 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              48 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              31 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              34 views
              0 likes
              Last Post TheRealMorford  
              Started by Mindset, 02-28-2026, 06:16 AM
              0 responses
              69 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X