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

Testing multiple contracts w/ diff. open times simultaneously - 15min bar start times

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

    Testing multiple contracts w/ diff. open times simultaneously - 15min bar start times

    Hello,

    First off, my users have been successfully using Ninja Trader to simultaneously backtest complex strategies on a massive number of contracts from many exchanges in many time zones, and think your product is fantastic.

    They are having no problems at all backtesting their strategies on 1 minute bars, but are having a problem simultaneously testing many contracts on 15 minute bars when the contracts have different open times.

    They would like the 15 minute bars for the markets that open at 7:20 to start at 7:20 (7:20-7:35, 7:35-7:50, etc.), but they would like the 15 minute bars for the markets that open at 7:15 to start at 7:15 (7:15-7:30, 7:30-7:45, etc.).

    They are able to accomplish this for a single contract by setting the "Session begins (local time)" to any time at or before the product's open time as long as the time difference is evenly divisible by 15 minutes (for instance, for the 7:20 contract, 12:20 AM and 1:20 AM work just as well as 7:20AM).

    They are also able to simultaneously test all the contracts that open 20 minutes after any hour using this technique.

    They would like to be able to simultaneously backtest a bunch of contracts at once, with many different open times (7:02, 7:05, 7:09, 7:10, etc.), and have their 15 minute bar open times all open at the correct session open for each product.

    How can they accomplish this?

    If they can do this, then they will be able to backtest a 15 minute bar strategy on every contract they have every traded over a period of many years from a single button click! That would be awesome!

    Thanks in advance!

    ChiTrader2000
    Last edited by ChiTrader2000; 04-08-2009, 02:39 PM.

    #2
    ChiTrader2000,

    Sorry I am not understanding what you mean. There is one session definition time used by your strategy. If you want varying start times you will have to build in logic yourself to limit the times processed per bar series.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_Josh,

      No problem. Let me explain...

      Some background on my Ninja Trader C# project... I have already done lots of work in C# with limiting the trading times per contract within my code... for instance, we have imported data with lots of 1 minute bar data that is outside of our preferred trading times, so I limit trading on a per contract basis to the preferred trading times defined in our SQL Server 2005 database (I get the Open/Close time in the Initialize() event and I don't allow trading on every OnBarUpdate() event for bars outside our trading times). This part works great so far.

      What I am unable to achieve in either the C# code or in the Backtest properties dialog box is to force 15 minute bars to start on the open times of each of the contracts in our 1000+ contract backtests, for two reasons:
      1. We are trying to backtest 100% of our 100+ products (thousands of contracts, many exchanges in many timezones with many strange session open times) at the same time (in the same big backtest). These products have open times that aren't all 0 or 30 minutes after the hour. For instance, some of our products might open at 7:20 or 8:20, whereas other products open at 7:15 or 8:15.
      2. The 15 minute bars in Ninja Trader always start from the "Session begins (local time)" time that the user sets in the user interface. The problem with this is that since we have products that start trading a number of minutes after the hour that is not always divisible by the number 15 (such as 7:20), we are currently unable to backtest our strategies on 15 minute bars on all of our products at the same time, because the 15 minute bars either all start at minutes past the hour like 0, 15, 30, 45, (which works great for products with session open times like 9:00 or 10:45) or all the 15 minute bars start at minutes past the hour like 5, 20, 35, 50 (which works great for products that open at times like 9:05, 9:20, or 9:35).
      We would like to be able to test our 15 minute bar strategies on all our products at once, even though they have many unusual session open times (some even start at times like 9:44 or 8:28). We would like the 15 minute bars to always start on the session open of each product.


      ------------------------------
      ------------------------------
      So my question is (sorry for the long post!)...
      Is there something I can do in code or something we can do in the user interface to make sure that, in a big backtest of lots of products with different session open times, that no single 15 minute bar would start before an open time and then close after it (In other words, we don't want any open times to be in the middle of any 15 minute bar. It is OK to have lots of bars before the open, but one bar should close on the session open time and the next bar should open on the session open time)?

      (Keep in mind that I can already achieve this for a single contract, but want to give my users the ability to backtest all our products from a single button click, instead of 100 button clicks (once per product)).
      ------------------------------
      ------------------------------

      Thank you very much for any help in advance!

      ChiTrader2000
      Last edited by ChiTrader2000; 04-08-2009, 07:14 PM.

      Comment


        #4
        ChiTrader2000,

        Unfortunately this is not supported. The only thing NT handles is one session definition for the primary instrument. All your other instruments just follow the same definition.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          NinjaTrader_Josh and the Ninja Trader Development Team,

          Thanks for the quick response.

          Is there any way that the next version of Ninja Trader can make this possible, either from the user interface or from the C# code?

          It would be a big selling point for those of us who want to use Ninja Trader to test multiple products at once.

          With just one button click, the user could test any strategy on every futures contract ever traded in the world, going back as many years as the user has data for, instead of having to constantly worry about which products open at what time. That would be remarkably powerful!

          Thank you very much for considering my request!

          ChiTrader2000

          Comment


            #6
            Originally posted by ChiTrader2000 View Post
            Is there something I can do in code or something we can do in the user interface to make sure that, in a big backtest of lots of products with different session open times, that no single 15 minute bar would start before an open time and then close after it (In other words, we don't want any open times to be in the middle of any 15 minute bar. It is OK to have lots of bars before the open, but one bar should close on the session open time and the next bar should open on the session open time)?

            (Keep in mind that I can already achieve this for a single contract, but want to give my users the ability to backtest all our products from a single button click, instead of 100 button clicks (once per product)).
            Here's a thought... It appears that the lowest common denominator among all the contracts that you're testing is 5 minutes. Use a 5 minute chart.

            In your SQL Server 2005 database for each contract, specify the minute on the hour that the contract should be evaluate during OnBarUpdate. Looks like there are 3 scenarios for your 15 minute contracts.

            Scenario 1: 00, 15, 30, 45
            Scenario 2: 05, 20, 35, 50
            Scenario 3: 10, 25, 40, 55

            For Contracts following Scenario 1:
            1a) When the 5-minute bar closes on 15, then you evaluate the bars.
            1b) When the 5-minute bar closes on 20, you ignore the bar for this contract.
            1c) When the 5-minute bar closes on 25, you ignore the bar for this contract.

            For Contracts following Scenario 2:
            2a) When the 5-minute bar closes on 15, you ignore the bar for this contract.
            2b) When the 5-minute bar closes on 20, then you evaluate the bars.
            2c) When the 5-minute bar closes on 25, you ignore the bar for this contract.

            For Contracts following Scenario 3:
            3a) When the 5-minute bar closes on 15, you ignore the bar for this contract.
            3b) When the 5-minute bar closes on 20, you ignore the bar for this contract.
            3c) When the 5-minute bar closes on 25, then you evaluate the bars.

            You would have to evaluate 5 bars of 5 minutes to get your 15 minute bar in your backtesting.

            Comment


              #7
              mgbloomfield,

              This is a very interesting possibility! Thanks for the great idea!

              I may end up doing this until hopefully Ninja Trader adds the "15 Minute Bar can start on user-defined Session Open Time for each product in a multi-product backtest" feature that would be so valuable.

              I am going to think this idea through and maybe program it. I will use 1 minute bars instead of 5 minute bars, as we trade some products with very strange open times.

              One issue with doing it this way is that the traders won't be able to see the results on the proper 15 minute bars in Ninja Trader, and part of trading system development from their perspective is being able to visually eyeball a bunch of trades produced from a trading idea.

              Other issues I will need to think through that I can think of are:

              1. Sparse data: Sometimes, a 15 minute bar may not have any trades in the last minute or minutes. I would need to close off the 15 minute bar on the last minute with trades (such as the 12th minute, if no trades in last few minutes) to trade in the 15 minute bar.

              2. Market breaks (such as in some Asia markets)... this is related to point #1.

              3. I would want to use my own calculated bar close time, instead of the end time of the last 1 minute bar, so the users could still use certain time functions as though the imaginary 15 minute bars were really closing at the times that the traders expect them to close at.

              Can anybody see any other potential issues with this very interesting way of potentially getting around this problem with backtesting multiple products at once?

              Perhaps this forum thread could serve as a full document on how to achieve this functionality based on mgbloomfield's idea in the previous post.

              Thanks again for this great idea!

              ChiTrader2000

              Comment


                #8
                Ninja Trader Development Team,

                Is there any way that the next version of Ninja Trader can make this possible, either from the user interface or from the C# code?

                For instance, could you make the "Session begins (local time)" Backtest dialog box property publicly available in a Strategy's "Initialize()" event. If you did, then your users would be able to change the "Session begins (local time)" value in the "Initialize()" event based on what futures product is about to be backtested, which would make the 15 minute bars start at the correct minute after the hour.

                It would be a big selling point for those of us who want to use Ninja Trader to test multiple products at once.

                With just one button click, the user could test any strategy on every futures contract ever traded in the world, going back as many years as the user has data for, instead of having to constantly worry about which products open at what time. That would be remarkably powerful!

                Thank you very much for considering my request!

                ChiTrader2000
                Last edited by ChiTrader2000; 06-04-2009, 10:48 AM.

                Comment


                  #9
                  Thank you for the suggestion. We will add it to our list of future considerations, but as you start up a backtest you can already punch in what you want the session times to be so I do not see why there is an issue here.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    NT7 introduces concept of session profiles. Profiels are assigned to instruments and thus, during a backtest, you can set the session to use the profile assigned to the instrument. I am not sure if this will help you or not.
                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      NinjaTrader_Ray,

                      I think "session profiles" may be just what I am looking for, but just to clarify:
                      1. Are you saying that if I do a backtest on 15 minute bars for 3 products at the same time, whose open times are 8:00 AM, 8:05 AM, and 8:10 AM, that I can set a different session profile for each of the 3 products and that the backtest will use each product's session profile to determine the open time for each products' backtest, and will therefore will create the 15 minute bars for each product starting at each products' respective open time (in the same backtest, not three different backtests)?
                      For instance, I would need the first product's 15 minute bars to be like:

                      8:00-8:15, 8:15-8:30, ...

                      But the second product's 15 minute bars should be like:

                      8:05-8:20, 8:20-8:35, ...

                      Thanks!

                      ChiTrader2000

                      Comment


                        #12
                        Originally posted by ChiTrader2000 View Post
                        NinjaTrader_Ray,

                        I think "session profiles" may be just what I am looking for, but just to clarify:
                        1. Are you saying that if I do a backtest on 15 minute bars for 3 products at the same time, whose open times are 8:00 AM, 8:05 AM, and 8:10 AM, that I can set a different session profile for each of the 3 products and that the backtest will use each product's session profile to determine the open time for each products' backtest, and will therefore will create the 15 minute bars for each product starting at each products' respective open time (in the same backtest, not three different backtests)?
                        For instance, I would need the first product's 15 minute bars to be like:

                        8:00-8:15, 8:15-8:30, ...

                        But the second product's 15 minute bars should be like:

                        8:05-8:20, 8:20-8:35, ...

                        Thanks!

                        ChiTrader2000
                        You hit the nail on the head!
                        RayNinjaTrader Customer Service

                        Comment


                          #13
                          NinjaTrader_Ray,

                          You made my day! This is really a big deal to our company and the product I am developing, and I really appreciate that the NinjaTrader development team is committed to continually making big improvements to an already very good piece of software.

                          Thanks again,
                          ChiTrader2000

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Kaledus, Today, 01:29 PM
                          5 responses
                          12 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by Waxavi, Today, 02:00 AM
                          1 response
                          8 views
                          0 likes
                          Last Post NinjaTrader_LuisH  
                          Started by alifarahani, Today, 09:40 AM
                          5 responses
                          23 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by gentlebenthebear, Today, 01:30 AM
                          3 responses
                          16 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by PhillT, Today, 02:16 PM
                          2 responses
                          7 views
                          0 likes
                          Last Post PhillT
                          by PhillT
                           
                          Working...
                          X