Expose opening range start and end times to clients

This commit is contained in:
moshferatu 2024-06-08 05:29:26 -07:00
parent de3397870e
commit 820f3108cd

View File

@ -180,7 +180,6 @@ namespace NinjaTrader.NinjaScript.Indicators
protected override void OnBarUpdate()
{
DateTime now = Times[BarsInProgress][0];
DateTime openingRangeStartTime = GetOpeningRangeStartTime(now);
if (Bars.IsFirstBarOfSession && IsFirstTickOfBar)
{
@ -189,7 +188,7 @@ namespace NinjaTrader.NinjaScript.Indicators
}
if (OpeningRangeBars == BarsInProgress &&
now > openingRangeStartTime && now <= GetOpeningRangeEndTime(openingRangeStartTime))
now > GetOpeningRangeStartTime(now) && now <= GetOpeningRangeEndTime(now))
{
if (CurrentOpeningRange == null)
{
@ -400,13 +399,14 @@ namespace NinjaTrader.NinjaScript.Indicators
return textOrigin;
}
private DateTime GetOpeningRangeStartTime(DateTime now)
public DateTime GetOpeningRangeStartTime(DateTime now)
{
return now.Date + RegularTradingHoursOpen;
}
private DateTime GetOpeningRangeEndTime(DateTime openingRangeStartTime)
public DateTime GetOpeningRangeEndTime(DateTime now)
{
DateTime openingRangeStartTime = GetOpeningRangeStartTime(now);
switch (OpeningRangeType)
{
case OpeningRangeBarType.Seconds: