Simple question... When I run the following code on HSI which has 2 sessions per day the print commands execute 4 times per day.
By my calculations if there are 2 sessions per day then "Bars.FirstBarOfSession" should only execute 2 times. Also, as you will see from the print below, the first two prints are at different times 9:46 (the first bar) then 10:00 (no idea why) then twice at 2:30pm, the Open of the afternoon session.
N.b. This is not a one off, it does it for the whole series.
Thoughts???
protected override void OnBarUpdate()
{
// Use the first day of simulation to initialize data
if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired || CurrentBars[2] < BarsRequired)
{
return;
}
if (Bars.FirstBarOfSession)
{
Print("Current DateTime: " + Time[0].ToString());
Bars.Session.GetNextBeginEnd(BarsArray[0], 0, out sessionBegin, out sessionEnd);
Print("Session Start: " + sessionBegin + " Session End: " + sessionEnd);
}
// SAMPLE OUTPUT
Current DateTime: 3/1/2011 9:46:00 AM
Session Start: 3/1/2011 9:15:00 AM Session End: 3/1/2011 12:00:00 PM
Current DateTime: 3/1/2011 10:00:00 AM
Session Start: 3/1/2011 9:15:00 AM Session End: 3/1/2011 12:00:00 PM
Current DateTime: 3/1/2011 2:30:00 PM
Session Start: 3/1/2011 1:30:00 PM Session End: 3/1/2011 4:15:00 PM
Current DateTime: 3/1/2011 2:30:00 PM
Session Start: 3/1/2011 1:30:00 PM Session End: 3/1/2011 4:15:00 P

Comment