View Full Version : Bars.LastOfSession
NinjaTrader_Josh
08-15-2007, 03:56 AM
May I suggest adding this bool to complement the Bars.FirstOfSession that is already available? It would be useful for indicators that need to reset values before the next session instead of at the start of the next session.
NinjaTrader_Dierk
08-15-2007, 04:07 AM
The problem with this is that you would not know if you have seen the last tick of a session until the session is over in which event no further OnBarUpdate method would be triggered -> LastOfSession always would be false in your OnBarUpdate method.
NinjaTrader_Josh
08-15-2007, 04:16 AM
I meant Bars not ticks. You should be able to know if this would be the last bar of the session based on what time the bar is building for. If the bar is building for any time past the Session End time then the bool should return true. This is how the Bars.FirstOfSession behaves too. It returns true anytime throughout the bar, not just at the first tick of the bar or the last tick of the bar.
While I'm on a Bars.* topic I noticed that Bars.SessionEnd produces a weird DateTime date. Using Bars.SessionBegin prints out "8/15/2007 6:30:00 AM", but Bars.SessionEnd prints out "7/27/2007 1:00:00 PM". Why are they different dates? This makes it useless to do a simple (Bars.SessionEnd-Bars.SessionBegin) for use in trying to create my own Bars.LastOfSession bool.
NinjaTrader_Dierk
08-15-2007, 04:19 AM
Got it. Will add to the list. Thanks for your suggestion.
The date portion of SessionBegin/End is irrelevant, only the time portion is.
NinjaTrader_Josh
08-15-2007, 04:29 AM
At the moment if I do Bars.SessionEnd-Bars.SessionBegin this is the output I get:
Session Begin: 8/15/2007 6:30:00 AM Session End: 7/27/2007 1:00:00 PM End-Begin: -18.17:30:00 It is taking the difference in dates not just times into the TimeSpan calculation.
NinjaTrader_Dierk
08-15-2007, 04:36 AM
Right, as explained below the date portion is irrelevant, it could have any value. Only the time portion is relevant. Your math below could return any result.