• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtest Properties window is empty

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

    Backtest Properties window is empty

    Hi there,
    I have a strategy (OnBarUpdate) and when I try to backtest it via Strategy Analyzer (choosing my strategy from list) I don't see any properties such as data series, time frame. This window is empty. I only see Run backtest button which do nothing.
    Maybe I should change smth in code?

    #2
    Hello Leeroy_Jenkins,

    Are there errors appearing in the Log tab of the Control Center?

    Specifically errors about Initialize() or the Constructor?


    If not, may I test an export of your script?

    To export a NinjaTrader 7 NinjaScript so this may be shared and imported by the recipient do the following:
    1. Click File -> Utilities -> Export NinjaScript
    2. Enter a unique name for the file in the value for 'File name:'
    3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
    4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message
    By default your exported file will be in the following location:
    • (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript\<export_file_name.z ip>
    Below is a link to the help guide on Exporting NinjaScripts.
    http://www.ninjatrader.com/support/h...nt7/export.htm
    Last edited by NinjaTrader_ChelseaB; 02-18-2019, 09:03 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello Leeroy_Jenkins,

      Are there errors appearing in the Log tab of the Control Center?

      Specifically errors about OnStateChange or the Constructor?


      If not, may I test an export of your script?

      To export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:
      1. Click Tools -> Export -> NinjaScript...
      2. Click the 'add' link -> check the box(es) for the script(s) and reference(s) you want to include
      3. Click the 'Export' button
      4. Enter a unique name for the file in the value for 'File name:'
      5. Choose a save location -> click Save
      6. Click OK to clear the export location message
      By default your exported file will be in the following location:
      • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
      Below is a link to the help guide on Exporting NinjaScripts.
      http://ninjatrader.com/support/helpG...-us/export.htm
      I use CalculateOnBarClose, not OnBarUpdate, my bad. No errors.
      Attached Files

      Comment


        #4
        Hello Leeroy_Jenkins,

        Are you 100% certain that there are no errors appearing on the Log tab of the Control Center?

        I am receiving errors in the Log tab of the Control Center.

        Please try testing the script again and look once more at the Log tab of the Control Center. Do you see any errors in yellow? If so, what do these say?

        This script is attempting to access bar information in Initialize() which is not allowed. You have to wait until OnBarUpdate() before you can start processing bar information.

        Please attempt to run the script again, then immediately after running the script please take a screenshot of the Log tab of the Control Center and then provide this screenshot with your next post.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello Leeroy_Jenkins,

          Are you 100% certain that there are no errors appearing on the Log tab of the Control Center?

          I am receiving errors in the Log tab of the Control Center.

          Please try testing the script again and look once more at the Log tab of the Control Center. Do you see any errors in yellow? If so, what do these say?

          This script is attempting to access bar information in Initialize() which is not allowed. You have to wait until OnBarUpdate() before you can start processing bar information.

          Please attempt to run the script again, then immediately after running the script please take a screenshot of the Log tab of the Control Center and then provide this screenshot with your next post.
          I run backtest at 11:13 and nothing happened. No results, no errors. But I found this:

          18.02.2019 11:11:21 Strategy Failed to call method 'Initialize' for strategy 'ADX6/0704599be6884fd1a3ca581361e0b8ec': Object reference not set to an instance of an object.

          My strategy is called ADX6.

          Comment


            #6
            Hello Leeroy_Jenkins,

            When you mention: "I run backtest at 11:13 and nothing happened. No results, no errors.", this is incorrect.
            There were errors.
            The errors are yellow in the Log tab of the Control Center.
            You even found the error that was produced when loading the script.
            "18.02.2019 11:11:21 Strategy Failed to call method 'Initialize' for strategy 'ADX6/0704599be6884fd1a3ca581361e0b8ec': Object reference not set to an instance of an object. "
            This is the error that is preventing your script from running.

            The error states the issue is that the script ADX6 cannot be Initialized.
            You have an error in Initialize.

            Please take a look at the Initialize method in ADX6 as directed by the error message that appears when attempting to load this script.

            Is there any invalid code in the Initialize() method in the ADX6 script?

            Keep in mind that bar information is not available in Initialize().
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post

              Keep in mind that bar information is not available in Initialize().
              I though if I need CalculateOnBarClose = true I should put my code into Initialize(). Am I wrong? Simple strategies from tutorial wrote like that...
              Could you please look at my code cuz I dunno where is a problem in Initialize(). I tried everything I know.
              Last edited by Leeroy_Jenkins; 02-18-2019, 03:57 PM. Reason: eu education

              Comment


                #8
                Originally posted by Leeroy_Jenkins View Post
                I though if I need CalculateOnBarClose = true I should put my code into Initialize(). Am I wrong?
                Yes, this is (very) wrong.
                Do you recall where you learned this from?

                Originally posted by Leeroy_Jenkins View Post
                Simple strategies from tutorial wrote like that...
                Which simple strategies? Please provide links.

                Originally posted by Leeroy_Jenkins View Post
                Could you please look at my code cuz I dunno where is a problem in Initialize(). I tried everything I know.
                I've looked at your code. It is not organized correctly.

                Except for the line where you set "CalculateOnBarClose = true", move all the other lines into OnBarUpdate.

                Originally posted by Leeroy_Jenkins View Post
                I use CalculateOnBarClose, not OnBarUpdate, my bad. No errors.
                The errors you are seeing are precisely because you are not using OnBarUpdate correctly.

                Have you studied any of the NinjaTrader sample strategies?

                Please note:
                Your code in attachment in post #3 is simply wrong.
                No sample strategy has any of the OnBarUpdate code placed inside Initialize.
                No tutorial would ever show code examples organized in that manner.

                Even though your code is wrong, you're very close, so do some simple editing and try again.
                Make sure you study and learn why your initial code attachment is organized incorrectly.
                Last edited by bltdavid; 02-18-2019, 10:20 PM.

                Comment


                  #9
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Is there any invalid code in the Initialize() method in the ADX6 script?
                  Except where OP initialized CalculateOnBarClose to true, OP's entire Initialize is nothing but invalid code.

                  Comment


                    #10
                    Hello Leeroy_Jenkins,

                    All of the code from lines 37 to 54 is accessing bar information and cannot be in Initialize(). Move this code to OnBarUpdate().

                    Below I am providing a link to a forum post with helpful information about getting started with NinjaScript. Please watch the NinjaScript Editor 401 video.
                    https://ninjatrader.com/support/foru...232#post775232
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by Leeroy_Jenkins View Post
                      I use CalculateOnBarClose, not OnBarUpdate, my bad. No errors.
                      As a new programmer, there are two basic categories of errors you are forever learning
                      to overcome:

                      Compile-Time errors:
                      Compiling your code finds language syntax errors, these errors must all be corrected before
                      you can even run your code. These errors are reported at the bottom of the NinjaTrader
                      editor window.

                      Run-Time errors:
                      These errors typically show a poor understanding of the language, they indicate things like
                      incorrect usage of concepts, improper organization of code, and non-sensical logic violating
                      language constraints. These errors are bad enough that the run-time environment (such as
                      NinjaTrader's Strategy Analyzer) will usually stop the program (aka, your indicator or strategy)
                      and print an error message. In our case all run-time error messages are sent to the log file,
                      which are viewable via the Log tab in the Control Center window.

                      The point is:
                      Just because your code compiles correctly, does not mean that other errors don't exist. Like
                      many terms in computer science, the word 'error' is very overloaded.

                      Although it deals with Java, this link has good general information about 'errors' in programming:
                      https://www.cis.upenn.edu/~matuszek/...ax/errors.html

                      Btw, yes, there is a third major category of errors, known as 'bugs'. When a program is able
                      to run to completion yet still produces incorrect results, the logic errors in the program causing
                      the incorrect results are called 'bugs'. A software bug can be exceptionally difficult to find
                      and become very notorious in its effects.

                      You code is a classic example of the "run-time error" category.

                      The philosophy section at the bottom of that link is very well said.
                      No one starts out writing perfect error-free programs.
                      Hang in there.
                      Last edited by bltdavid; 02-19-2019, 11:41 AM.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by futurenick, Today, 06:26 AM
                      1 response
                      9 views
                      0 likes
                      Last Post nkhoi
                      by nkhoi
                       
                      Started by NinjaCustomer, Today, 12:29 PM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_ShawnB  
                      Started by Steve L, Today, 11:32 AM
                      0 responses
                      5 views
                      0 likes
                      Last Post Steve L
                      by Steve L
                       
                      Started by prabbala, Today, 10:41 AM
                      0 responses
                      3 views
                      0 likes
                      Last Post prabbala  
                      Started by bebbus, Today, 10:36 AM
                      0 responses
                      4 views
                      0 likes
                      Last Post bebbus
                      by bebbus
                       
                      Working...
                      X