View Full Version : Session Break for first session?
dave1992
10-13-2009, 05:23 AM
Hello,
SessionBreak and FirstBarOfSession don't seem to get set for the first session? If I run this code below, for most contracts (6A, NKD etc) and put in a session of 17:00 to 17:05, for three days, you get no first bar or session break on the first day.
What am I missing?
thanks
Dave
protected override void OnBarUpdate()
{
if (Bars.FirstBarOfSession) {
Print("First Bar");
}
if (Bars.SessionBreak) {
Print("Session Break");
}
Print("here");
}
NinjaTrader_Bertrand
10-13-2009, 06:40 AM
Dave, thanks - can't reproduce here on my end - which chart interval are you using when you see this?
dave1992
10-13-2009, 10:05 AM
Hi,
1 min chart, NKD 12-09, start 6 sep end 8 sep, start session 17:00, end session 17:10
thanks
Dave
NinjaTrader_Bertrand
10-13-2009, 10:32 AM
Dave, this produces an empty chart with no bars so the behavior would be expected.
dave1992
10-15-2009, 07:17 AM
Hi Bertrand,
Thanks for the reply. You need to check your chart, there is definitely data. See attached chart. In any case, I wouldn't have been able to spot that there was no session break on the first day if there'd been no data.
In any case, this is a strategy problem. I suspect that this will occur for any instrument. I just checked and it does. FirstBar works but sessionbreak doesn't.
Does the manual page for session break need to change to say it isn't set for the first session in a run?
Dave
NinjaTrader_Bertrand
10-15-2009, 08:34 AM
Thanks Dave, could finally see the behavior you see and it's expected for the first session break, since there's no session to record a break from at the start of your chart. You could use FirstBarOfSession in combo with FirstTickOfBar for this.
dave1992
10-15-2009, 08:39 AM
Thanks, yes I figured that out. It may be worth clarifying on the web pages since it's not really obvious.
NinjaTrader_Bertrand
10-15-2009, 08:42 AM
Ok, I see - thanks for the input Dave.