• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What is BarsSinceSession

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

    What is BarsSinceSession

    I've noticed that BarsSinceSession returns the same int asCurrentBar so what's the actual use of it?

    And what exactly is the meaning of 'Session'? is it the time of the current trading session? the time of opening a new chart? of loading the indicator?

    Thanks.

    #2
    Hello savekad,
    Bars since session returns how many bars has elapsed since the start of the session.
    http://www.ninjatrader.com/support/h...ncesession.htm

    Session is the session template you apply on the chart via the Data Series parameter dialog.
    http://www.ninjatrader.com/support/h...on_manager.htm
    Last edited by NinjaTrader_Joydeep; 08-23-2012, 03:45 AM.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      So it is the number of bars since the starting of the session according the to session template in use?

      That means that there could be a chart loaded with bars of two sessions, and the BarsSinceSession will return the number of bars for the current one, ignoring the previous one, correct?

      Comment


        #4
        I've checked. According to my test the answer is yes.

        Comment


          #5
          Hello savekad,
          Yes, if you have data for 2 sessions then the Bars.BarsSinceSession will return the bar number of the latest/current session.
          JoydeepNinjaTrader Customer Service

          Comment


            #6
            Hello, I have a question.

            When I am using Bars.BarsSinceSession >= 2 , it works perfectly in the morning session, there will be no trades until the third bar. However during the afternoon session, trading starts from the first bar. I am using the ose session template.

            Thanks in advance.

            Comment


              #7
              Confusion between session and trading day

              This is one of the well known NinjaTrader bugs. For many NinjaScript methods there is a confusion about the concept of a trading session and a trading day, as originally, when the software was designed, the difference between "trading day" and "session" was not understood.

              The method Bars.BarsSinceSession returns the bar number since the start of the trading day. The first bar of the trading day is counted as zero.The counting does not reset at the beginning of the afternoon session. NinjaTrader here calls the trading day a session.

              There are quite a few other problems resulting from this confusion. For example in a strategy all orders GTD (good till day), will be cancelled at the end of the session instead at the end of the trading day. For that reason I am now partly coming back to the use of single session trading days, when running automated strategies. NinjaTrader here calls the session a trading day, which is the reverse problem to the one encountered above.

              Please make sure that this confusion is being sorted out for NinjaTrader 8!
              Attached Files

              Comment


                #8
                Hello beierde888,

                What Harry said is correct. Basically, if there are multiple Sessions within one calendar day NinjaTrader will not reset the BarsSinceSession until the next calendar day (based on your Local PC).

                I believe it is more of a design limitation but either way that is something on our Enhancement list for NT8 NinjaScript.

                Let me know if you have any questions.
                Last edited by NinjaTrader_JC; 07-24-2013, 07:06 AM.
                JCNinjaTrader Customer Service

                Comment


                  #9
                  But it is easy to calculate the number of bars since the session start. Here is the code

                  Code:
                  # region Variables
                  private int count = 0;
                  ........
                  #endregion
                  
                  protected override void OnBarUpdate()
                  {
                       if (FirstTickOfBar)
                       {
                           if (Bars.FirstBarOfSession)
                               count = 0;
                           else
                               count = count + 1;
                       }    
                  .......
                  }
                  Now you just need to access count for your purpose.

                  Comment


                    #10
                    Thanks for the code Harry, that helped a lot!

                    Comment


                      #11
                      Is BarsSinceSession correct when Historical is true or is it only valid for the last bar of the chart?

                      Is that the same for FirstBarOfSession too?

                      Comment


                        #12
                        Originally posted by adamus View Post
                        Is BarsSinceSession correct when Historical is true or is it only valid for the last bar of the chart?

                        Is that the same for FirstBarOfSession too?
                        Both Bars.FirstBarOfSession and Bars.BarsSinceSession can be accessed for both historical and real-time data. Bars.FirstBarOfSession is a Boolean, which holds the value "true" for the first bar of each session and which holds the value "false" for all other bars. Bars.BarsSinceSession returns an integer which holds the value of the number of bars elapsed since the session start.
                        Last edited by Harry; 01-24-2015, 06:56 AM.

                        Comment


                          #13
                          OK thanks.

                          Do you know whether FirstBarOfSession is true only for the bar at the time of the session start, or if I am missing a bar of data at the start, will the next bar be true instead?

                          Comment


                            #14
                            Hello adamus,

                            Bars.FirstBarOfSession will be true on the first Bar of the new session even if it is 5 mintues after the session has started if there is no data to generate a bar.

                            Let us know if we can be of any further assistance.
                            JCNinjaTrader Customer Service

                            Comment


                              #15
                              More Confusion between session and trading day

                              First of all: I'm a noob re: NT7, but have quite some programming experience in my previous life, however I'm at a loss regarding this Bars.BarsSinceSession thing ...

                              1. I want to find the High/Low for a certain range of time, let's say: What's the High/Low from 00:00:00h until 15:29h?

                              2. I want to find the bar within that timeframe which has the highest amount of volume tied to it (e.g. at 09:07 the volume was the highest at 4501 contracts traded that minute)

                              I spent the whole day digging up various sources, but I'm at a loss, so hopefully some of you nice people can point me in the right direction. Thanks much in advance.

                              - ABC

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by trader252, Today, 08:38 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post trader252  
                              Started by ralett, Today, 06:20 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post ralett
                              by ralett
                               
                              Started by grizzlytrader, Today, 06:24 AM
                              1 response
                              20 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by andrewtrades, Today, 01:43 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by FuturesRon, Today, 03:09 AM
                              1 response
                              18 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X