I'm trying to replicate the same functionality of Exit On Session Close with ExitOnSessionCloseSeconds=30
But the following code exiting time is not matching the internal Exit On Session Close times.
if(BarsInProgress == 2) // Referring to the Additional Ticks DataSeries
{
#region ExitOnSession Close
sessionIterator.GetNextSession(Times[2][0], true);
// store the desired session information
DateTime tradingDay = sessionIterator.ActualTradingDayExchange;
DateTime beginTime = sessionIterator.ActualSessionBegin;
DateTime endTime = sessionIterator.ActualSessionEnd;
if(BarsArray[2].IsFirstBarOfSession)
{
CheckEOS = true;
}
if(Times[2][0].AddSeconds(30).TimeOfDay >= endTime.TimeOfDay && CheckEOS)
{
if(
Position.MarketPosition == MarketPosition.Long
&& BUY_entryOrder!=null
)
{
ExitLong(2,Convert.ToInt32(DefaultQuantity), @"EOSBUY", @"BUY");
}
CheckEOS = false;
}
#endregion
}

Comment