Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Identify First Bar of New Period

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

    How to Identify First Bar of New Period

    Hi

    Is there an example or simple way to identify the first bar (and last too) of a new week, month, quarter, year - even day as well ?

    My objective is to look back in time and identify hilo ranges of periods such as last week, last month etc.

    thanks

    #2
    Take a look at Time[0].* Perhaps you could work with that info.

    --EV

    Comment


      #3
      thx

      that tells what the time is now, it doesn't say if its start of a new week or month or day or whatever

      thx

      Comment


        #4
        Originally posted by Sniffy View Post
        that tells what the time is now, it doesn't say if its start of a new week or month or day or whatever

        thx
        It tell time of a bar -- Time[int barsAgo] You can get back a DateTIme structure, or it has various parsing of the date/time, such as Time[0].DayOfWeek.

        --EV

        Comment


          #5
          thx

          yes I know what it does but I dont think your replies answer my original post

          thx

          Comment


            #6
            Sniffy, ETFVoyageur did answer your post. You will have to look at the data in each Time[x] DateTime structure to determine when a bar existed. To check when the first bar occurs of a new day, for example, you'll have to continuously monitor the current day of Time[0] (Time[0].Date or Time[0].Day if you only want the day component of the date), and when a new day shows up (if currentDay != dayOfLastBar), mark that bar because it is a new day.

            For more information on DateTime structures, please take a look at this MSDN page.

            There is also a sample for how to manipulate DateTime information.
            AustinNinjaTrader Customer Service

            Comment


              #7
              seems we will have to agree to disagree, pointing me at time and telling me to work it out for myself is not my idea of an answer to my question - at least its not the type of answer I would give

              onwards and upwards

              Comment


                #8
                Originally posted by Sniffy View Post
                seems we will have to agree to disagree, pointing me at time and telling me to work it out for myself is not my idea of an answer to my question - at least its not the type of answer I would give

                onwards and upwards
                From this post, I am not sure what you are seeking. Are you seeking a completed indicator written to do what you want, or information for you to code such a requirement? You have been given all the information needed to code the requirement. I can provide some pseudo-code to demonstrate the concept, but I am not sure if that will satisfy your wants, as same do not seem to be stated, and you got the kind of response that I at least, would expect from the way that you asked the question.

                Code:
                bool _boolNewMonth = (Time[0].Month != Time[1].Month);
                if (_boolNewMonth) {//code to handle the month switch}
                et.c.,
                Last edited by koganam; 01-29-2011, 08:53 PM.

                Comment


                  #9
                  strange response

                  the question was asked in a perfectly neutral tone

                  I certainly don't need or want your crass admonishments

                  Comment


                    #10
                    Originally posted by Sniffy View Post
                    the question was asked in a perfectly neutral tone

                    I certainly don't need or want your crass admonishments
                    What an interesting way to react to responses to a request for help. You must have a great many friends, or else a great many slaves who do your bidding with minimal instruction.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    571 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    331 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    101 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    549 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    549 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X