GetTradingDayEndLocal()

View as Markdown

Definition

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

Property Value

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

Syntax

\<sessioniterator\>.GetTradingDayEndLocal(DateTime tradingDayExchange)

Parameters

ParameterDescription
tradingDayExchangeThe DateTime value used to calculate the trading day.

Examples

1private SessionIterator sessionIterator;
2protected override void OnStateChange()
3{
4 if (State == State.DataLoaded)
5 {
6 //stores the sessions once bars are ready, but before OnBarUpdate is called
7 sessionIterator = new SessionIterator(Bars);
8 }
9}
10protected override void OnBarUpdate()
11{
12 // Only process strategy logic up until three hours prior to the end of the trading day at the exchange
13 if (Core.Globals.Now <= sessionIterator.GetTradingDayEndLocal(sessionIterator.ActualTradingDayExchange).AddHours(-3))
14 {
15 // Strategy logic here
16 }
17}