セッションの次の開始/終了を表す日時を返す。
注記:返される値は、同一のセッションについて一組にされたものである。次のDateTimeがセッションの終了日時である場合、そのセッションの終了日時に対応する開始日時と一組にされて、開始日時は返される。それはその終了日時の後の、次の開始日時ではない。
DateTime構造体
Bars.Session.GetNextBeginEnd( DateTime time , out DateTime sessionBegin , out DateTime sessionEnd ) Bars.Session.GetNextBeginEnd( Bars bars , int barsAgo , out DateTime sessionBegin , out DateTime sessionEnd )
/* Note: The two different signatures do not necessarily produce the exact same results.
When using the Bars signature, it compares the bar you request versus where that bar
belongs within a session template and provides you session begin/end times that way.
When using the Time signature, it compares the timestamp of the bar to figure out
the session begin/end.
When using the Time signature, if you passed in a timestamp with exactly
the same timestamp of a session begin/end it compares them
as if the session begin/end was an inclusive time frame so it may return values
for session begin/end of the prior session despite the bar in question being of a new session.
If you want it to match the Bars' session template positioning please use the Bars signature. */
// Example #1 - Get session begin/end times in relation to the bar you are processing
private DateTime sessionBegin;
private DateTime sessionEnd;
protected override void OnBarUpdate()
{
// On the start of a new session, get the next begin or end session time
// and its corresponding paired session begin/end time.
if (Bars.FirstBarOfSession)
Bars.Session.GetNextBeginEnd(BarsArray[0], 0, out sessionBegin, out sessionEnd);
Print("Session Start: " + sessionBegin + " Session End: " + sessionEnd);
}
// Example #2 - Get session begin/end times in relation to a timestamp versus the session template's begin/end times
private DateTime sessionBegin;
private DateTime sessionEnd;
protected override void OnBarUpdate()
{
// At 10AM, get the next begin or end session time and its corresponding paired session begin/end time.
if (ToTime(Time[0]) == 100000)
Bars.Session.GetNextBeginEnd(Time[0], out sessionBegin, out sessionEnd);
Print("Session Start: " + sessionBegin + " Session End: " + sessionEnd);
}