Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting "begin" and "end" dates programmatically?

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

    Setting "begin" and "end" dates programmatically?

    Hi,

    Is there any way to programmatically access (or modify) the parameters within "time frame", in the back-testing menu? For back-testing, I'd love to be able to just select a specific time period (see: earlier question about enum) instead of having to type everything in by hand, every tmie.

    #2
    Once you set the session times, it will use the same sessions times when you run the backtest again.

    It keeps the same sessions times until you shut down NinjaTrader. Then when you boot up NinjaTrader, it will use the default session times.

    Comment


      #3
      Originally posted by mgbloomfield View Post
      Once you set the session times, it will use the same sessions times when you run the backtest again.

      It keeps the same sessions times until you shut down NinjaTrader. Then when you boot up NinjaTrader, it will use the default session times.
      I iterate through a number of different backtesting periods... and would like to automate that, instead of punching it in by hand.

      Comment


        #4
        Originally posted by heech View Post
        I iterate through a number of different backtesting periods... and would like to automate that, instead of punching it in by hand.
        In that case, leave the default session times as 12:00:00 AM and 12:00:00 AM.

        In your case, you'll need to set up private variables that would define your session times and trade between your private session variables.

        How you set up and update your private session variables depends entirely on your overall backtesting framework.

        Perhaps, during initialization, your strategy would read a config file to pull in the private session times.

        Comment


          #5
          Originally posted by mgbloomfield View Post
          In that case, leave the default session times as 12:00:00 AM and 12:00:00 AM.

          In your case, you'll need to set up private variables that would define your session times and trade between your private session variables.

          How you set up and update your private session variables depends entirely on your overall backtesting framework.

          Perhaps, during initialization, your strategy would read a config file to pull in the private session times.
          I did consider that approach... but my sessions look like this:

          - test symbols A1-Z1 from Jan 1st until Feb 1st,
          - A2-Z2 from Feb 1st until March 1st,
          -A3-Z3 ...

          Having a single session that runs from (let's say) Jan 1st - Dec 31st for ALL of the symbols ever touched seems like huge overhead. I'd like to be able to select (via a single parameter) "Jan"... and automatically the begin/end dates will also be set.

          Comment


            #6
            Originally posted by heech View Post
            I did consider that approach... but my sessions look like this:

            - test symbols A1-Z1 from Jan 1st until Feb 1st,
            - A2-Z2 from Feb 1st until March 1st,
            -A3-Z3 ...

            Having a single session that runs from (let's say) Jan 1st - Dec 31st for ALL of the symbols ever touched seems like huge overhead. I'd like to be able to select (via a single parameter) "Jan"... and automatically the begin/end dates will also be set.
            Session times are different per month? I think you actually want different session times per symbol?

            Perhaps, create a config file with two columns. The first column is the symbol. The second column is a string of sessions times. Read the file into a key value collection. The symbols go into the key. The session time goes into value. For a given symbol, pull out the session time from the value and parse the string into two separate session start and end times.

            Or something like that.

            Just figure out the "lowest programming cost", ya know what I mean

            Comment


              #7
              Originally posted by mgbloomfield View Post
              Session times are different per month? I think you actually want different session times per symbol?

              Perhaps, create a config file with two columns. The first column is the symbol. The second column is a string of sessions times. Read the file into a key value collection. The symbols go into the key. The session time goes into value. For a given symbol, pull out the session time from the value and parse the string into two separate session start and end times.

              Or something like that.

              Just figure out the "lowest programming cost", ya know what I mean
              I don't think you have any idea what I want to do.

              I have 400-600 symbols used over the course of a year... but only about 50 are used in any particular month. Right now, I already do use a local configuration file that lists the symbols used in any particular month... I then read the file, and Add() the symbols I'm using.

              But that still means I have to go into 'Backtest', scroll down to Timeframe, type in '01/15/2008' and '02/17/2008', and then click 'backtest'.

              I'd prefer not having to memorize (and re-type) the start/end dates of each month. I'd prefer to just go into Backtest, and click on "TEST A" (on a enum parameter), and then "TEST B", and then "TEST C", etc.

              Comment


                #8
                Originally posted by heech View Post
                I don't think you have any idea what I want to do.

                I have 400-600 symbols used over the course of a year... but only about 50 are used in any particular month. Right now, I already do use a local configuration file that lists the symbols used in any particular month... I then read the file, and Add() the symbols I'm using.

                But that still means I have to go into 'Backtest', scroll down to Timeframe, type in '01/15/2008' and '02/17/2008', and then click 'backtest'.

                I'd prefer not having to memorize (and re-type) the start/end dates of each month. I'd prefer to just go into Backtest, and click on "TEST A" (on a enum parameter), and then "TEST B", and then "TEST C", etc.
                Add all 600 symbols that you will use for the entire duration of the backtest.

                Your config file denotes which symbols are active for each month.

                In your OnBarUpdate, examine Time[0] to determine the month the backtest is in. In turn, this determines which symbols are "active" for that month (based on the config file you loaded).

                Will that work?

                Comment


                  #9
                  Originally posted by mgbloomfield View Post
                  Add all 600 symbols that you will use for the entire duration of the backtest.

                  Your config file denotes which symbols are active for each month.

                  In your OnBarUpdate, examine Time[0] to determine the month the backtest is in. In turn, this determines which symbols are "active" for that month (based on the config file you loaded).

                  Will that work?
                  I'm already doing exactly that internally in each month, actually. These symbols aren't all being traded all month.. some start earlier, end earlier, etc. So, I've considered expanding it to the full year.

                  But what I want to avoid is loading a year's worth of data x 500 symbols. I question whether NT can handle it, and I think the (wasted) overhead would be huge.

                  Comment


                    #10
                    Originally posted by heech View Post
                    I'm already doing exactly that internally in each month, actually. These symbols aren't all being traded all month.. some start earlier, end earlier, etc. So, I've considered expanding it to the full year.

                    But what I want to avoid is loading a year's worth of data x 500 symbols. I question whether NT can handle it, and I think the (wasted) overhead would be huge.

                    I was wondering the same thing.

                    Can symbols be added/removed during OnBarUpdate? If yes, then you could code it so that it only add/remove symbols that you need at the beginning of each month (or whatever your "timeframe" is).

                    Comment


                      #11
                      Unfortunately not mgbloomfield.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      571 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      331 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      101 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      549 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      550 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X