Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Last bars of previous session

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

    Last bars of previous session

    Is there a way to see the high / low of the last 5 bars of the previous session? I would like to know the high / low range of the last 5 minutes of the previous day session.

    Thanks

    #2
    Hello siroki,

    Thank you for your post.

    You can check the last five bars when the current bar is the first bar of the session and use highest and Lowest Bar to determine the range.
    Code:
    			if(Bars.FirstBarOfSession)
    			{
    				double last5MinRange = High[HighestBar(High, 5)] - Low[LowestBar(Low, 5)];
    			}

    Comment


      #3
      That's what I already tried, but it just gives the first bar of the session. It doesnt seem to be able to look at individual bars before the current session.
      Last edited by siroki; 03-24-2014, 01:41 AM.

      Comment


        #4
        Hello Siroki,

        Thank you for your response.

        My previous example would include the first bar of the new session. Please try the following to calculate this on the last bar of the session:
        Code:
                private DateTime sessionBegin;
        		private DateTime sessionEnd;
                protected override void OnBarUpdate()
                {
        			if(Bars.FirstBarOfSession)
        			{
        				Bars.Session.GetNextBeginEnd(BarsArray[0], 0, out sessionBegin, out sessionEnd);
        			}
        			
        			if(Time[0] == sessionEnd)
        			{
        				double last5MinRange = High[HighestBar(High, 5)] - Low[LowestBar(Low, 5)];
        				Print(last5MinRange);
        			}
                }
        For information on GetNextBeginEnd() please visit the following link: http://www.ninjatrader.com/support/h...xtbeginend.htm

        Comment


          #5
          Ah, interesting solution. I wasn't aware of the Bars.Session.GetNextBeginEnd method.

          Do you think it would be a safer to use if(Bars. BarsSinceSession == 390) compared to if(Time[0] == sessionEnd)? I heard sometimes it might give problems with daylight saving etc.

          btw: 390 are the number of 1 minute bars in a session.

          Thanks for your help!
          Last edited by siroki; 03-27-2014, 03:17 AM.

          Comment


            #6
            Hello siroki,

            I can see how that may be effected by Day Light Savings. If the Bar count will equal 390, then you can attempt this as well.

            Comment

            Latest Posts

            Collapse

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