GetTradingDayBeginLocal()

View as Markdown

Definition

Converts the trading day begin time from the exchange timezone to local time, and returns a DateTime object in the local timezone. The ActualTradingDayExchange property can be passed into GetTradingDayBeginLocal() for a quick timezone conversion.

Property Value

A DateTime object representing the exchange-based trading day begin time converted to local time.

Syntax

\<sessioniterator\>.GetTradingDayBeginLocal(DateTime tradingDayExchange)

Parameters

ParameterDescription
tradingDayExchangeThe DateTime value used to calculate the trading day.

Examples

1private SessionIterator sessionIterator;
2
3protected override void OnStateChange()
4{
5 if (State == State.DataLoaded)
6 {
7 //stores the sessions once bars are ready, but before OnBarUpdate is called
8 sessionIterator = new SessionIterator(Bars);
9 }
10}
11
12protected override void OnBarUpdate()
13{
14 // Only process strategy logic starting three hours after trading begins at the exchange
15 if (Core.Globals.Now >= sessionIterator.GetTradingDayBeginLocal(sessionIterator.ActualTradingDayExchange).AddHours(3))
16 {
17 // Strategy logic here
18 }
19}