Crashing based on
Crashing based on
15 Aug 2019, 04:58
Hi,
I would like help with this date/time error.
I have the following function defined:
public DateTime TradingDateTime()
{
if (this.IsBacktesting)
{
return Server.Time;
}
return TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local);
}
But, when I call this onBar with the following code:
DateTime toda = TradingDateTime();
DateTime today = toda.Date.AddHours(-7);
int lastBarIndex = MarketSeries.OpenTime.GetIndexByTime(today) + 1;
I get the following error:
15/08/2019 11:50:00.900 | Crashed in OnBar with ArgumentException: The conversion could not be completed because the supplied DateTime did not have the Kind property set correctly. For example, when the Kind property is DateTimeKind.Local, the source time zone must be TimeZoneInfo.Local. Parameter name: sourceTimeZone
What am I doing wrong here?
Replies
sascha.dawe
26 Aug 2019, 13:53
Hi Panagiotis,
Thanks for taking the time to research this problem.
This thread solved my problem.
Much Appreciated,
Sascha
@sascha.dawe
PanagiotisCharalampous
26 Aug 2019, 09:56
Hi Sascha,
Chaeck this thread, it might be helpful for you.
Best Regards,
Panagiotis
@PanagiotisCharalampous