GetTradingDay()

View as Markdown

Definition

Returns the actual trading date based on the exchange, calculated from a DateTime object passed with the local time. GetTradingDay() calls CalculateTradingDay() on a custom SessionIterator object created by passing in a Bars object as an argument.

Warning: This method can ONLY be called when a SessionIterator was created with a ‘Bars’ parameter.

Property Value

A DateTime object representing the ActualTradingDayExchange.

Syntax

\<sessioniterator\>.GetTradingDay(DateTime timeLocal)

Parameters

ParameterDescription
timeLocalThe DateTime value used to calculate the next trading day.

Examples

1// Declare a new custom SessionIterator
2SessionIterator mySessionIterator;
3
4protected override void OnStateChange()
5{
6 if (State == State.Historical)
7 {
8 // Instantiate mySessionIterator once in State.Configure
9 mySessionIterator = new SessionIterator(BarsArray[0]);
10 }
11}
12
13protected override void OnBarUpdate()
14{
15 // Obtain the ActualTradingDayExchange value for mySessionIterator, based on today's date
16 Print(mySessionIterator.GetTradingDay(DateTime.Now).ToString());
17}