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 charlesugo_1, 05-26-2026, 05:03 PM
            0 responses
            60 views
            0 likes
            Last Post charlesugo_1  
            Started by DannyP96, 05-18-2026, 02:38 PM
            1 response
            147 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 05-11-2026, 05:56 AM
            0 responses
            161 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 05-10-2026, 08:12 PM
            0 responses
            97 views
            0 likes
            Last Post CarlTrading  
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            284 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Working...
            X