Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

session templates and first bar of session

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

    session templates and first bar of session

    Hi,

    If I pick a future, FGBM, and run this for 2-4 Dec in backtest

    protected override void OnBarUpdate()
    {
    if (Bars.FirstBarOfSession) {
    Print(Time[0].ToString());
    }
    }

    I get

    03/12/2009 07:02:00
    04/12/2009 07:02:00

    That's with session template set to default instrument settings. If I change the session template to Default 24/5, and re-run, I get

    02/12/2009 07:02:00
    03/12/2009 07:02:00
    04/12/2009 07:02:00

    The thing is, the default for that instrument is Eurex FI Futures, which is Mon-Fri 0800-2200 (European Time)

    So, why do I not get the 2 Dec FirstBarOfSession set for that?

    thanks
    Dave

    #2
    dave1992,

    Please try setting BarsRequired to 0 and try again.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      OK, thanks, that works, and I can sort of see why. I don't understand why the different behaviour for the two session templates.

      I would like to use the default template, but I need to access the previous session closing bar on the first session the strategy runs. If BarsRequired is zero, that bar is not available.

      Comment


        #4
        dave1992,

        Easiest way could just be to add time filter checks and backtest on a longer time range. Any dates before your specified date will be effectively ignored.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Hi,

          I still don't understand the difference between the two templates. Sorry for going on about that, but I'd really like to know how they work in this case, since I'd like to use them.

          The problem I'd have is if I decided to start a live strategy, at 6am, an hour before the session starts, would I get the first bar of session flag, and would I have access to yesterday's close. My worry is that I wouldn't.

          thanks
          Dave

          Comment


            #6
            Dave,

            I would not be able to tell you without seeing your exact data set. What happens when you use Default 24/7 session is that your session begins at 12AM EST. That will get adjusted to whatever timezone you are located in. For example 12/8 12AM EST would translate to a session beginning 12/7 9PM PST. Then however your data meshes into this exact session template is how it proceeds.

            It is all based off of what bars you have on your chart. Session templates filter bars out so if you end up filtering out the BarsRequired bars to get you before the session then that is what happens.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              OK, I see what you're saying, but in that case the word session means a very different thing in 'session template' to the sessions we've been used to.

              If a session template can filter out the 'FirstBarOfSession', then session template is really just time filter template. Otherwise you would expect session template start time to define the first bar of session as being the first bar received after that start time.

              Comment


                #8
                Not sure I follow? In 6.5, "sessions" were managed by whatever start/end time you set to Chart Properties. Now, you have what we call "Session Templates" where you can create session definitions for various days of the week. Each with its own start/end time which would then become your session start/end times.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Well, it may be that I never came across this in 6.5 and 6.5 has the same issue.

                  My point remains though, that if you define the start time of a session, then the first bar received after that start time should set FirstBarOfSession. You are implying that maybe I've filtered out the bar that would trigger that. If that really is the case then the word session in FirstBarOfSession and in "session template" really do mean different things.

                  thanks
                  Dave

                  Comment


                    #10
                    Dave,

                    Like I said, without actually seeing complete data I will not be able to evaluate your situation.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Well, you can see the data if you run the test I described in the original post.

                      I don't see why need data however to answer the first bar of session question. There must be logic for setting it - investigating that logic would surely explain whether it's set, or should be set, for the first bar after a session template start.

                      thanks
                      Dave

                      Comment


                        #12
                        Dave,

                        To start things off, a timestamp of 7:02 does not make sense in relation to any of your session templates to begin with. That is why I need to know exactly how your whole data set looks like. Likely has to do with the instrument simply not trading, or you missing data.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi Josh,

                          The first tick of the day was 07:01:02, which is bar 07:02 right? Let me rephrase myself and see if that helps. I can say the first bar of each day is 07:02 (GMT) and the last is about 21:04.

                          If I start a strategy at 6am tomorrow, and the first bar of tomorrow is 07:02, and I want the previous day's bar, if I use session template default 24/5 I will get firstbaroftheday set for the 07:02 bar, implying that setup somehow gets a bar before 07:02 to satisfy barsreq = 1. If I use the default instrument settings, I don't get firstbarofsession set for the 07:02 bar, implying that 07:02 gets missed to satisfy barsreq = 1.

                          So, default 24/5 would start the session at 00:00 tonight, and default instrument would start the session at 08:00 (CET) which is 07:00 (GMT)

                          So, I suspect that if you start a strategy on a particular day with 24/5, it pulls in all bars from Monday 00:00 even if you start on a Tuesday. Is that what's happening here. That would explain the difference.

                          thanks
                          Dave

                          Comment


                            #14
                            Precisely.
                            Default 24/5 starts 00:00 Eastern. Whether that dips into Monday on your Tuesday depends on the particular local timezone in relation to Eastern time.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              No, we're not quite there yet. 7am GMT is 2am ET. The previous day's last tick is 4pm ET. Besides, it doesn't just dip into the day, it gets all data for the day, since it prints out a 7:02 bar for the day before.

                              So, is this expected behaviour for Default 24/5? And if so, what's the reason for it?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by GwFutures1988, Today, 02:48 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post GwFutures1988  
                              Started by mmenigma, Today, 02:22 PM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by frankthearm, Today, 09:08 AM
                              9 responses
                              35 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by NRITV, Today, 01:15 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post NRITV
                              by NRITV
                               
                              Started by maybeimnotrader, Yesterday, 05:46 PM
                              5 responses
                              28 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X