IsNewSession()

View as Markdown

Definition

Indicates a specified time is greater than the ActualSessionEnd property on the configured Trading Hours template.

Property Value

A bool value when true indicates the specified time is later than ActualSessionEnd; otherwise false.

Parameters

ParameterDescription
timeThe DateTime value used to compare
includesEndTimeStampA bool determining if a timestamp of <n>:00 should fall into the current session. (e.g., used for time based intraday series such as minute or second).

Syntax

\<sessioniterator\>.IsNewSession(DateTime time, bool includesEndTimeStamp)

Examples

1bool takeTrades;
2
3protected override void OnBarUpdate()
4{
5 // Switch a bool named takeTrades to false when IsNewSession() returns true.
6 if (Bars.SessionIterator.IsNewSession(DateTime.Now, true)) ;
7 {
8 Alert("EOS", Priority.Medium, String.Format("New session beginning. Waiting until {0} to begin trading again"), " ", 5, Brushes.Black, Brushes.White);
9 takeTrades = false;
10 }
11
12 // Set the bool back to true on the first bar of the new session
13 if (Bars.IsFirstBarOfSession)
14 takeTrades = true;
15}