Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problems with ticks happening at session EndTime

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

    Problems with ticks happening at session EndTime

    Suppose I use the Default 24/7 session template.

    It means that I have session times :
    HTML Code:
                               StartTime                             EndTime
    Session 1       25/10/2010 06:00:00            26/10/2010 06:00:00
    Session 2       26/10/2010 06:00:00            27/10/2010 06:00:00
    etc
    Problem is that if I call GetNextBeginEnd(26/10/2010 06:00:00, BeginTime,EndTime)

    I get
    BeginTime=25/10/2010 06:00:00
    EndTime=26/10/2010 06:00:00

    Where I think the correct answer is
    BeginTime=26/10/2010 06:00:00
    EndTime=27/10/2010 06:00:00

    The tick happening at 26/10/2010 06:00:00 should actually first tick of 26/10 session, not last tick of 25/10 session, meaning EndTime in session templates should be excluded from the session times.


    The same kind of problems happens with Volume[0].
    I have session data on the ES that has a tick of volume 1 happening exactly at 06:00:00

    For testing purposes I made an indicator that cumulated volume of the day
    PHP Code:
            protected override void Initialize()
            {
                
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line"CumVol"));
                
    Overlay                false;
                Print(
    " ");
                Print(
    BarsPeriod.Id+" "BarsPeriod.Value);
            }

            
    /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            
    protected override void OnBarUpdate()
            {
                
    // Use this method for calculating your indicator values. Assign a value to each
                // plot below by replacing 'Close[0]' with your own formula.
                

                
                
    if (Bars.FirstBarOfSession)
                {
                    if (
    CurrentBar>0)
                        Print(
    Time[1]+" "+cumvol);
                        
                    
    cumvol=0;
                }
                
                
    cumvol += (int)Volume[0];
                
    CumVol.Set(cumvol);

            } 
    On second charts, the volume sum of the day should always be constant, but choosing different values of second interval gives different sum of volume : sometimes the tick at 06:00 is included, sometimes it is not
    (session in question is the last one: volume is either 1757247 either 1757246)
    Second 22
    10/11/2010 05:59:54 2323115
    11/11/2010 05:59:54 2514853
    12/11/2010 06:00:00 1757247

    Second 26
    10/11/2010 05:59:58 2323115
    11/11/2010 05:59:58 2514853
    12/11/2010 05:59:58 1757247

    Second 34
    10/11/2010 05:59:54 2323115
    11/11/2010 05:59:54 2514853
    12/11/2010 06:00:00 1757247

    Second 38
    09/11/2010 06:00:00 3
    10/11/2010 06:00:00 2323115
    11/11/2010 06:00:00 2514853
    12/11/2010 06:00:00 1757246

    Second 39
    10/11/2010 06:00:00 2323115
    11/11/2010 06:00:00 2514853
    12/11/2010 06:00:00 1757247

    Second 30
    09/11/2010 06:00:00 3
    10/11/2010 06:00:00 2323115
    11/11/2010 06:00:00 2514853
    12/11/2010 06:00:00 1757246

    Second 15
    10/11/2010 06:00:00 2323115
    11/11/2010 06:00:00 2514853
    12/11/2010 06:00:00 1757247

    Second 20
    10/11/2010 06:00:00 2323115
    11/11/2010 06:00:00 2514853
    12/11/2010 06:00:00 1757247

    Second 10
    10/11/2010 05:59:50 2323115
    11/11/2010 06:00:00 2514853
    12/11/2010 06:00:00 1757247

    Second 32
    09/11/2010 06:00:00 3
    10/11/2010 06:00:00 2323115
    11/11/2010 06:00:00 2514853
    12/11/2010 06:00:00 1757246

    #2
    gomi, sorry for our late reply here - we'll look into matters and get back to you.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      gomi, when would you call your GetNextSessionBeginEnd? I tried a call at session break on ES 1 tick and see this output, whicb would be expected -

      11/15/2010 12:00:01 AM Session Start: 11/15/2010 12:00:00 AM Session End: 11/16/2010 12:00:00 AM
      BertrandNinjaTrader Customer Service

      Comment


        #4
        Yes, but you tried 12:00:01, not 12:00:00

        Comment


          #5
          That would not be the session break then, the new bar starts as the closing tick of the last is received - this is the 12:00:01 tick here - opening tick of the new session.
          BertrandNinjaTrader Customer Service

          Comment


            #6
            If I have session start at 8:30:00 for CME for instance, I will have lots of ticks at the open , which is at the 8:30:00 second. These ticks during the whole 00 second belong to the new session, don't they ?

            Comment


              #7
              NinjaTrader stamps the bar at their close, thus you would need to set the session to begin at 8:29:59 to also use the first closed tick bar in your new session (the 8:30:00 closed one).
              BertrandNinjaTrader Customer Service

              Comment


                #8
                ????? Sorry, this is not how ninja works.....

                I made a quick indicator showing ticks and bar volumes with their timestamps
                HTML Code:
                         protected override void OnBarUpdate()
                        {
                            // Use this method for calculating your indicator values. Assign a value to each
                            // plot below by replacing 'Close[0]' with your own formula.
                        
                        if ((FirstTickOfBar) && (CurrentBar>1))
                            Print("BAR : "+Time[1]+ " "+Volume[1]);
                
                        }
                
                        protected override void OnMarketData(MarketDataEventArgs e)
                        {
                            if (e.MarketDataType==MarketDataType.Last)
                                Print("Tick : "+e.Time+" "+e.Volume);
                        }
                I follow ES using instrument defaults, so session start is 15:30:00 Paris time.
                Here are the results:

                Tick : 27/10/2010 15:29:59 7
                Tick : 27/10/2010 15:30:00 1
                BAR : 26/10/2010 22:14:59 18
                Tick : 27/10/2010 15:30:00 34
                Tick : 27/10/2010 15:30:00 22
                Tick : 27/10/2010 15:30:00 435
                Tick : 27/10/2010 15:30:00 1
                Tick : 27/10/2010 15:30:00 2
                .
                .
                .
                .

                Tick : 27/10/2010 15:30:00 4
                Tick : 27/10/2010 15:30:00 1
                Tick : 27/10/2010 15:30:00 50
                Tick : 27/10/2010 15:30:00 4
                Tick : 27/10/2010 15:30:00 200
                Tick : 27/10/2010 15:30:01 250
                BAR : 27/10/2010 15:30:00 2797
                Tick : 27/10/2010 15:30:01 25
                Tick : 27/10/2010 15:30:01 16


                So as you can see the 15:30:00 ticks are used, no need to use a 15:29:59 session start time....

                Comment


                  #9
                  Unfortunately I am not following you. The bars are most definitely timestamped with the closing timestamp of the bar. If it is a tick based bar then it will be the timestamp of the last tick in that bar. If it is a time based bar then it will be whatever ending timestamp of that time frame would be.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    This subject has moved to timestamping of the bar but it is totally irrelevant to my issue.

                    Reread first post : I am only stating that if session begin time==session end time, 06:00:00 for instance, the GetNextBeginEnd has to choose if the tick is in last bar of previous session or first bar of next session.

                    It chooses to decide it belongs to the last bar of previous session which is not logical, because if Begin Time != End Session, like 8:30:00 and 15:00:00, the 8:30:00 tick is included in the session and the 15:00:00 tick is excluded (last tick of session is 14:59:59)

                    So Begin Time should be considered inclusive, and End Time exclusive, which mean the 06:00:00 tick we mentioned should be first tick of next session

                    Which means GetNextBeginEnd (10/10/2010 06:00:00) should give
                    Begin Time=10/10 End Time 11/10 and not
                    Begin Time=9/10 End Time 10/10

                    like it does today

                    Comment


                      #11
                      Code:
                      FirstBarOfSession Time: 11/15/2010 6:01:00 AM Session Start: 11/15/2010 6:00:00 AM Session End: 11/16/2010 6:00:00 AM
                      PC clock set to GMT+1.
                      First bar of the session is timestamped as 6:01AM which is the end timestamp of a 1min bar equivalent to what my chart is using. Now we check out GetNextBeginEnd, providing me accurate 11/15 to 11/16.

                      Running off a 150-tick chart now...
                      Code:
                      FirstBarOfSessionTime: 11/15/2010 6:09:32 AM Session Start: 11/15/2010 6:00:00 AM Session End: 11/16/2010 6:00:00 AM
                      The exact timestamp of 6:00:00AM belongs to the prior session. Data with timestamp later than 6AM belongs to the new session.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Josh View Post
                        The exact timestamp of 6:00:00AM belongs to the prior session
                        Yes, I know, this is my very point. Does it seem logical to you ?

                        Imagine the flow of the ticks with a millisecond granularity.

                        If we set start/end session at 06:00:00, we will get with your solution all the ticks from
                        06:00:01.000 to next day 06:00:999

                        If you decide to include begin time and exclude end time, we will get all ticks from
                        06:00:00.000 to next day 05.59.999, which seems much more what we are willing to do when we set start/end session at 06:00:00 ...

                        Or maybe is it "by design" ?

                        Comment


                          #13
                          We plan to have a resolution to this with NinjaTrader 7.0.1000.5.
                          BertrandNinjaTrader Customer Service

                          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