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

exit on session close inconsistent in backtests

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

    exit on session close inconsistent in backtests

    I've been experiencing an ongoing issue with my strategies exiting positions on session close inconsistently in NT8 backtests. For example, in Analyzer settings I have set "exit at session close" to false. I have also checked that in Tools>Options>Trading settings that "auto close positions" is disabled. Regardless, my strategies often exit positions on session close (15:59:59 CST) while running backtests with these settings. Is there a solution?

    #2
    Hello 2inthebush,

    Thank you for your note.

    Even if Exit on Session Close is not checked, any position open at the end of the Strategy Analyzer data you are testing over will be exited with an "Exit on Session Close" order. This is expected. We would not expect to see Exit on Session Close orders anywhere else in the backtest but the very last position closed.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      The behavior that I'm describing is that my strategies will exit at session close at the end of every session in the test data, including the end of the test data. For example, if there are several days in the test data range then my strategies will exit at session close of each day at 15:59:59 CST, and then exit at the end of the test data range. Plus the behavior is inconsistent from one test to the next.

      Comment


        #4
        Hello 2inthebush,

        Thank you for your reply.

        If Exit On Session Close is not checked we wouldn't expect to see that. Would you be able to provide a screenshot of a Strategy Analyzer run in which this is not checked and you're seeing this on a session which is not the last session of the Strategy Analyzer run? Please make sure that the exit on session close setting is visible in the screenshot after running the strategy with this unchecked.

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Alright, I've attached a screenshot as you've described.
          Attached Files

          Comment


            #6
            Hello 2inthebush,

            Thank you for your reply.

            I'm not seeing this occur on my end when using the same settings for Historical Fill Processing and Optimize sections on ES 12/21 data when testing with the Sample MA CrossOver that is built into the platform. Please test on your end with the Sample MA CrossOver using the same settings as in your screenshot on the same data series you're using to test this strategy and ensure Exit at Session Close is not checked - do you see it exiting on the close of the session each day, or only at the end of the run?

            Thanks in advance; I look forward to assisting you further.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              OK, I'll try that and report on my results.

              I also just noticed frequent errors in my logs. I'm seeing a lot of errors about "failed to set property for... [strategy]... system argument null exception: value cannot be null...". Maybe this is related to the exit on session close issue.

              Comment


                #8
                So far I haven't been able to reproduce the issue in tests of Sample MA CrossOver, using the same test settings as previous tests of my strategies. So I presume that this indicates some sort of error within my strategies.

                I also see that the Sample MA CrossOver generated the same error in my logs as above: "failed to set property for... [strategy]... system argument null exception: value cannot be null...". I don't know how to interpret the errors in my log files. Would you be able to look at my log files in order to determine what the errors indicate?
                Last edited by 2inthebush; 09-23-2021, 04:04 PM.

                Comment


                  #9
                  Hello 2inthebush,

                  Thank you for your reply.

                  Yes, I would be happy to look at your log and trace files. Because these can contain personally identifiable information, we'll have you send them in directly from the platform rather than post them here.

                  You can do this by going to the Control Center-> Help-> Email Support

                  Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default.

                  Please reference the following ticket number in the body of the email: 3277277 ATTN Kate W. Also, please put a link to this thread in the email as well.

                  Thanks in advance; I look forward to assisting you further.
                  Kate W.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks, Kate. I'll send those soon. Do the log/trace files remain after restarting the NT platform? I needed to restart my platform after my last post, and no further log errors have occurred since.

                    Also, it seems that I've found a workaround for the "exit at session close" issue. I switched my trading hours template from "CME US index futures ETH" to "default 24x7" . So far, this has resolved the issue. I had presumed that the trading hours would be irrelevant if Exit at Session Close is disabled. However, maybe my assumption was incorrect?

                    Comment


                      #11
                      Hello 2inthebush,

                      Thank you for your reply.

                      Yes, your log and trace files remain for the session after a restart - each time you restart a new log and trace for that session is created and added to either the log or trace folder.

                      That would make sense as the Default 24/7 template does not have session breaks, however, it does not explain why you are seeing session breaks when testing that strategy in particular or why you are getting the error message. We'll still need to take a look at the logs.

                      Thanks in advance; I look forward to assisting you further.
                      Kate W.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi Kate W, I've sent my log and trace files per your instructions above.

                        I've also noticed in my recent Analyzer tests that NT is still inconsistently exiting at the close of two different sessions (15:59:59 and 22:59:59), even while the "default 24x7" trading hours are selected. More specifically, this causes a mismatch between the test results displayed in the main results window versus the results displayed in the test summary window below. I've included screenshots of this issue. The results displayed in the main results window represent when NT works properly with "exit on session close" disabled. The results in the lower summary window represent NT exiting at session close, despite "exit at session close" being disabled. In other words, the test ran properly at first... but then NT switched to "exit at session close" enabled behavior when I later selected the test results to view the summary window. Hope that makes sense.
                        Attached Files
                        Last edited by 2inthebush; 09-27-2021, 04:29 PM.

                        Comment


                          #13
                          I've managed to mostly eliminate these issues after editing the default strategy settings in Builder. Also, there have been no further errors in my logs. In the default strategy settings, I disabled "exit at session close" and I changed "minimum bars to trade" to 1 bar.

                          For a while, this completely eliminated all of the issues that I've described. However, after running more tests in Analyzer, I returned to the results of my recent tests that I ran after changing the default strategy settings. Now the results of these previous tests showed discrepancies between the upper results window and the summary window below, while they had not shown any discrepancies before running further tests. Fortunately, I see no further issues with incorrect "exit at session close" behavior. Instead, the results show small discrepancies in the P&L, total trades, and other performance data. This is progress, at least.

                          At this point, it seems that I should create these strategies again from scratch to see if I can completely eliminate these test result discrepancies. After several edits in Builder, I suspect that somehow my strategies became corrupted, and that is causing these erratic results in Analyzer.
                          Last edited by 2inthebush; 09-28-2021, 12:38 AM.

                          Comment


                            #14
                            Hello 2inthebush,

                            Thank you for your reply.

                            I've responded to the email you sent with the log and trace files, so before you jump to recreating the strategies, I'd first try the uninstall/reinstall to ensure nothing from the prior install may be causing issues.

                            That being said, I would also clear your cache to ensure cached data isn't the issue with the results not matching between the list at the top and the actual results shown at the bottom:

                            To delete the cache, follow the steps below.
                            • Shut down NinjaTrader.
                            • Open the Documents > NinjaTrader 8 > db folder.
                            • Delete the sub-folder named 'cache'.
                            • Restart NinjaTrader and test.
                            Thanks in advance; I look forward to assisting you further.
                            Kate W.NinjaTrader Customer Service

                            Comment


                              #15
                              I've completed all of the steps as instructed, and restarted NT8. No errors, and compiling completed successfully. However, none of my prior tests are loading in Analyzer. Is it possible to port that test data over to the new installation, without risking corrupting the fresh installation with possible issues from the prior installation?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Tim-c, Today, 03:54 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Tim-c
                              by Tim-c
                               
                              Started by FrancisMorro, Today, 03:24 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post FrancisMorro  
                              Started by Segwin, 05-07-2018, 02:15 PM
                              10 responses
                              1,770 views
                              0 likes
                              Last Post Leafcutter  
                              Started by Rapine Heihei, 04-23-2024, 07:51 PM
                              2 responses
                              31 views
                              0 likes
                              Last Post Max238
                              by Max238
                               
                              Started by Shansen, 08-30-2019, 10:18 PM
                              24 responses
                              945 views
                              0 likes
                              Last Post spwizard  
                              Working...
                              X