Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtesting smaller timeframes impossible, please help

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

    Backtesting smaller timeframes impossible, please help

    Hello all,

    I know that what I need is not supported in NT (at least it seems to me), so I want ask if someone found a workaround for the following problem:

    I want backtest smaller timeframes (under timeframes I do not mean the bar size, I mean timeframe worth of data).

    For example I want to backtest a strategy on 3 days worth of date, as an example, day 19-21 of this month and session time 12Am to 12Am (it must be this concrete 3 days and only this 3 not more and not less), using 20000 volume bars.
    The strategy uses for example a 200ema so it needs 200bars before day 19 to test correctly day 19-21 which of course are not there and of this 3 days 1 cannot be tested because the indicator would not be correct.

    Not shore if I explain myself clear, if you baktest 1 year of data lose one or 2 days will not change to much the results but if you backtest only 3 days or so and you need 20, 50 or 200 bars only for the indicator to start working ... ITS SIMPLY IMPOSIBLE

    It would help if you could specify both, the quantity of data to use and from which to which day test (for example, if I want test day 19-21, include data worth from 17-21 so the indicator is fully operational but the strategy analyzer runs the test only for day 19-21) OR
    If you specify you want test day 19-21 12Am-12Am and in "Min.bars required" specify 200 that 200bars before 12Am day 19 are included in the backtest data and the backtest runs correctly from 12Am day 19 and not day 19 after 200 bars are formed which using something like 20000 volume could be half or even 1 day.

    As it is now I do not see any possibility to run backtests or optimizations’ in NT on smaller time frames, it would be worthless because they would be totally wrong (I want backtest day 19-21 but it skips half day 19, if I tell him to optimize 18-21 its still totally wrong because the 200 bars maybe formed in the middle of day 18 so I am testing half day more than I want)

    Thanks in adwanse!

    #2
    You can just increase the start to end date for backtesting and in your strategy use DateTime variables to limit actual trading to certain dates.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      backtest of pervious "X" period

      Over the weekend I like to write up a weekly report of trading system results. So on the one hand I need to limit the test exactly to the previous week, but on the other hand I need to make sure there are enough bars for my indicators to work properly. If you plot a 200 period TSF you can see that there is a period of time when the indicator is plotting and capable of genrating signals but it is clearly "wonky" and parabolic looking until enough data is loaded to give proper signals. Having to re-write the code in the strategy each week to get the proper time period tested seems crazy (no offense). So far the best I've come up with is having the backtest produce a chart with the indicators and more than enough "bars required" for all my various systems and then watch the chart as I adjust the start time period on the back test so that the proper first signal of the week is produced. This seems quite awkward. I hope Ninja can change the backtest so that setting a given date for the backtest to start forces the program to get whatever bars are needed to properly run the test. This is not the case currently -- example using TSF198 and 200 on a 15 min chart. I want the test to start 3/30. If I set 3/30 and 250 min bars required the backtest waits 250 bars into the week before starting. Instead I have to fool with the chart and backtest to determine that I have to set the test to start on 3/12 in order to hit the first signal on 3/30 -- see attached. Strangely enough sometimes I have to first set the date further back till I have too many signals and then work it forward -- otherwise sometimes the first signals of the week don't show. Is there any better way to do this or if not can the backtest be improved?
      Attached Files

      Comment


        #4
        bkout,

        The easiest way to get what you want is just to run an all inclusive backtest and just limit it in your code to your desired dates.

        Code:
        if (ToDay(Time[0]) < 20090406)
             return;
        You can even make that 20090406 an int parameter and it would be even easier for you to do this limiting.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Clearly everything becomes easier if one can write code. However for those of us that cannot doesn't it seem like we should be able to set the date for a backtest to start without having to go through so much?

          Comment


            #6
            bkout,

            Unfortunately those are the options already available to you. The Wizard cannot cover every possible case scenario you may want and what you want falls into the realm of programming. If you want this professionally done for you I do recommend one of the 3rd party NinjaScript Consultants here: http://www.ninjatrader.com/webnew/pa...injaScript.htm
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Sorry if I'm sounding whiny about this but I think your "every possible case" comment is dismissive of a real problem in Ninja's backtest setup. Say someone wants to compare 3 different systems with different indicators for trading SPY. They cannot do this by setting the date at say Dec 1 and running 3 backtests. This seems very basic and I'm not sure why there is any advantage to the system the way it is set up. IMO Ninja should be designed so that basic things like backtests to compare systems can be done without hiring someone to write code.

              Comment


                #8
                bkout,

                For sure you can set the dates to Dec1 and have it work with different indicators. Using the same "# of bars required" parameter will mean you use the same data. Ensuring the parameter is set sufficiently high to cover the unstable period for all of your indicators is up to you.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  But the test will not start on Dec 1. It will start after the "number of bars required" and different indicators will start signaling at different points in time-- if the person wants a real test from Dec 1 they will have to go through what I've been doing with the charts to "start the test" at an earlier date to allow a first signal on or after Dec 1. Then they will have to do the same thing with each system. Sorry but it just doesn't make sense.

                  Comment


                    #10
                    Not following you. Indicators all start when the minimum required bars parameter is met. If some are starting before others that means you have chose a setting that is improper and you need to increase the number of required bars. Default is 20.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      OK, sorry -- I thought I had seen indicators start at different points even though more than enough bars were loaded but I haven't been able to reproduce that. So my assumption is that I should pick the longest period in an indicator under consideration say 200 and then maybe add a little extra so say load 220 bars -- sound right? That's not a problem if the indicators all start at the same point. But why not have Ninja load the 220 from before the test start date rather than after? Is there some advantage? I would think most users would not realize that they have to figure out which date is 220 15 min bars into the past in order to get their test to start when they want.

                      Comment


                        #12
                        bkout,

                        This is a chicken-egg discussion. We can't do before simply because some people may not have data before. If they don't then we would be stuck.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          OK, I see, but I would think generally people have data available so why not make the default to backload the data required to start the test on the specified date, but have an option on the setup "Start data loading on test start date." Sorry to go on about this but I think the other programs I've used (MetaStock, StrategyDesk, InvestorRT) all were easier in that one just plugged in the start date and the program figured out how far back to access the data.

                          Comment


                            #14
                            bkout,

                            Thank you for the suggestion.
                            Josh P.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by algospoke, Yesterday, 06:40 PM
                            2 responses
                            23 views
                            0 likes
                            Last Post algospoke  
                            Started by ghoul, Today, 06:02 PM
                            3 responses
                            14 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by jeronymite, 04-12-2024, 04:26 PM
                            3 responses
                            45 views
                            0 likes
                            Last Post jeronymite  
                            Started by Barry Milan, Yesterday, 10:35 PM
                            7 responses
                            22 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by AttiM, 02-14-2024, 05:20 PM
                            10 responses
                            181 views
                            0 likes
                            Last Post jeronymite  
                            Working...
                            X