Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtesting bar interval

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

    Backtesting bar interval

    I have a basic question. It appears that the only historical data that I can load must be in 1 minute bars. Is this correct? The manual appears to say this; and fiurthermore I've had no luck trying to load 2 minute bar data.

    Rick
    Last edited by jonesr227; 08-21-2007, 03:28 AM.

    #2
    >> It appears that the only historical data that I can load must be in 1 minute bars.
    Incorrect, you can run your strategy on any minute series you'd like. Just (a) run it on a 2 minute chart or (b) start it on a 2 minute series in the strategies tab or (c) backtest it on a 2 minute series using the strategy analyzer.

    Comment


      #3
      Originally posted by NinjaTrader_Dierk View Post
      >> It appears that the only historical data that I can load must be in 1 minute bars.
      Incorrect, you can run your strategy on any minute series you'd like. Just (a) run it on a 2 minute chart or (b) start it on a 2 minute series in the strategies tab or (c) backtest it on a 2 minute series using the strategy analyzer.
      OK, so now I need to know how I can import 2 minute data into NT. I have successfully done this for 1 minute data, but following the same procedure for 2 minute data resulted in the error message "Instrument is not supported by repository". Prior to this I did use the instrument manager to set up the new name of the data that I hoped to import. Here again, I'm confused by the fact that there appears to be little lattitude in choosing instrument names. For example, I had previously imported 1 minute ER2 data and I gave it the name "ER2 09-07"; now for 2 minute data for ER2 I gave it a name "ER2 03-07" but this resulted in the above error message.
      Can I give more descriptive names such as "ER2_1min" and "ER2_2min"?
      I haven't been able to find out how.

      Comment


        #4
        Let's not confuse things:

        a) Instrument names have nothing to do with data series. As you have imported 1 minute bare series for ER2 09-07, any (!) minute series, including 2 minute series for ER2 09-07 is readily available and you can run tests on it a per my post below.

        b) If you want to run test on the ER2 03-07 you need to import data for that instrument as well, since it just a different instrument.

        c) Before testing any instrument I suggest you add it to your instrument list by: Tools->Instrument manager. This is a limitation of NT6 and will be come by fall time.

        Comment


          #5
          Originally posted by NinjaTrader_Dierk View Post
          Let's not confuse things:

          a) Instrument names have nothing to do with data series. As you have imported 1 minute bare series for ER2 09-07, any (!) minute series, including 2 minute series for ER2 09-07 is readily available and you can run tests on it a per my post below.

          b) If you want to run test on the ER2 03-07 you need to import data for that instrument as well, since it just a different instrument.

          c) Before testing any instrument I suggest you add it to your instrument list by: Tools->Instrument manager. This is a limitation of NT6 and will be come by fall time.

          I understand that having imported 1 minute data that I can now run any (integral multiple) bar interval. Therefore I understand your point (a) above. Also (as I mentioned in my prior post) I did use the Instrument Manager to add the instrument name; so I also understand your point (c) above.

          Point (b) however appears to require qualification. When you say "If you want to run test on the ER2 03-07 you need to import data for that instrument as well", apparently implicit in this is that this new data must be in 1 minute bars. Which leads me to my very original question: "It appears that the only historical data that I can load must be in 1 minute bars. Is this correct?" So the answer is in fact yes. Sorry for belaboring this but I need to have a clear understanding of this.

          Comment


            #6
            ER2 09-07 and ER2 03-07 are two different instruments, like MSFT and DELL are two different instruments.

            Not sure what you mean by "loading data": if you mean importing then yes, you only can import 1 minute series (and not 2 minute series), if you mean running a strategy then no, and my post below stands.

            Comment


              #7
              Dierk,

              Thank you very much for your help.

              As I learn about NT, I was baffled to find in regards to data that ,
              (at present):
              1) only 1 minute interval bars can be imported,
              2) only specific names can be used with the data.

              By the way, (not withstanding the above issues) I think NT is a terrific
              product. I'm actually hoping that it will replace my current backtester.
              (There's no longer any reason to use a backtester that uses interpreted code).

              Comment


                #8
                1) You can import 1 minute, 1 tick and 1 day series. All other series are created by NT internally. No need to import anything else.
                2) Not sure what you mean by "only specific names can be used with the data".

                Comment


                  #9
                  Tick Data in Back Testing

                  I am testing a strategy and trying to see if it can be improved using a trailing stop. I'm using a 377 tic interval on the ER2 (the september 07 contract). I'm using mirus/zenfire for my historical data. I find that if I use a low value of for the trail interval (say 2 tics) I get fantastic results for the strategy but when I run those same values in real-time, I get terrible results. I understand that backtesting versus real-time will not be the same, but I'm struggling to understand how I can use backtesting to improve a strategy when the delta between back versus real is so huge. It must be the way a tick bar is built in the historic data. Can you provide more detail about how that tic is built. If I run a 377 tick interval in backtesting, are there 377 tics, all time-stamped inside that bar or is there a different methodology. If the strategy can't look "inside" a bar, why do I get trailing stop hits inside the bar the position is taken in? I have the strategy set to execute on the bar close, and all my positions start on the open of the next bar.

                  Comment


                    #10
                    Hi Daven,

                    When you are backtesting there is only one bar timestamped and not 377 ticks inside that bar with each timestamped. This is why we can't "look" inside the bar for more clarity. You get a trailing stop because it just assumes you would have gotten filled at x level. It looks at the OHLC and determines if sometime within that bar you would have been stopped out and it will do so at your trailing stop price. The reason all your positions start at the beginning of the next bar is related to the "look" inside limitation. Because the only time you would know the OHLC of a bar is at the end of the bar, the only time you can act is right now and not in the past. Right now means the start of the new bar. Hope that helps clarify things.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Inside BackTesting Bar Details

                      Josh,
                      Thanks for that clarification. That explains what I've been seeing in testing versus reality. Is there a way to run a strategy so that the strategy entry is executed on the close of a bar, but any trailing or stop positions would be executed within a bar, (not wait for the bar to close)?
                      Daven

                      Comment


                        #12
                        Unfortunately there is no steadily available method to do so. This is the reason why you cannot just backtest your strategy. You also need to forward test it. Personally, the way I forward test my strategy is from replay files.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Excuse my previous comment. I misunderstood your question. You can set CalculateOnBarClose == true to have your strategy entry only execute on the bar close. You can then use SetTrailStop() to manage your stops. Even when CalculateOnBarClose == true the SetTrailStop() will be updated tick by tick so it will exit for you within the bar.

                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            May I jump in here. I believe I have been trying to do what daven is talking about. Using single tick historical data I am attempting to backtest a strategy that is based on 30 minute indicators. I open a position correctly at the close of a 30 minute bar, but it appreas that even using SetTrailingStop() my position is not updated until the close of the next 30 minute bar. This happens if CalculateOnBarClose is true or false.

                            Do I misunderstand?

                            Thanks

                            Comment


                              #15
                              Hi kgillis23,

                              During backtesting you will enter the trade on the next bar after you place your order. This is the case for normal entries and exits via the EnterLong() ExitShort() methods. Technically speaking, the order is placed and filled at the open of the next bar because the close of the current bar is already past history and you can't affect history.

                              In regards to the SetTrailStop() method. It sends orders that will be executed on the bar it is triggered even in backtesting. It will not wait for the bar to close to exit your already existing position. The logic behind this is because if the stop price is triggered anywhere during the bar it would have closed right there. Does that make sense? The SetTrailStop() is unaffected by which setting you have CalculateOnBarClose at while regular entry and exit methods are affected by it.

                              Hope that clarifies things.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              45 responses
                              3,992 views
                              3 likes
                              Last Post johntraderuser2  
                              Started by TAJTrades, Today, 09:46 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post TAJTrades  
                              Started by rhyminkevin, Yesterday, 04:58 PM
                              5 responses
                              62 views
                              0 likes
                              Last Post dp8282
                              by dp8282
                               
                              Started by realblubb, Today, 09:28 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post realblubb  
                              Started by AaronKoRn, Yesterday, 09:49 PM
                              1 response
                              19 views
                              0 likes
                              Last Post Rikazkhan007  
                              Working...
                              X