DateTimeKind.Local is not supported
DateTimeKind.Local is not supported
05 May 2020, 16:45
Hi there:
I want to draw a rectangle that starts from the current bar and extends to the right for 11 hours (eg, bars that haven't opened yet).
I can't figure out how to get this code to work:
_barTimesStart = DateTime.SpecifyKind(Bars.Last(0).OpenTime, DateTimeKind.Local);
_barTimesEnd = DateTime.SpecifyKind(_barTimesStart.AddHours(15 - 4), DateTimeKind.Local);
if (_barTimesStart.Hour == 4 && _barTimesStart.Minute == 0)
{
_marketSeriesDailyTimeFrame.OpenTimes.GetIndexByTime(DateTime.SpecifyKind(_barTimesEnd.ToLocalTime(), DateTimeKind.Local));
Chart.DrawVerticalLine("VL" + _barTimesStart.ToShortDateString(), index, Color.Cyan, 3, LineStyle.Dots);
Chart.DrawText("DT" + _barTimesStart.ToShortDateString(), _barTimesStart.ToString(), index, Result[index], Color.Cyan);
//This line throw the exception
ChartRectangle rectangle = Chart.DrawRectangle("REC" + _barTimesStart.ToShortDateString(), _barTimesStart, Result[index] + (Symbol.PipSize * 500), _barTimesEnd, Result[index] - (Symbol.PipSize * 500), "44888888", 1, LineStyle.Solid);
rectangle.IsFilled = true;
}
else if (_barTimesStart.Hour == 15 && _barTimesStart.Minute == 0)
{
Chart.DrawVerticalLine("VL" + _barTimesEnd.ToShortDateString(), index, Color.Cyan, 3, LineStyle.Dots);
Chart.DrawText("DT" + _barTimesEnd.ToShortDateString(), _barTimesEnd.ToString(), index, Result[index], Color.Cyan);
}
I keep receiving this exception message regardless of what I try:
Anyone have any tips of guidance please? I want all times as per the times I have on the chart (currently UTC + 8)
Thank you.
Replies
firemyst
06 May 2020, 09:04
RE:
PanagiotisCharalampous said:
Hi firemyst,
Why do you use DateTime.SpecifyKind() function?
Best Regards,
Panagiotis
I was using it because I wanted time converted to local time.
instead, I added ".ToLocalTime()" onto the datetime objects where I needed it to convert for printing.
Thank you.
This code has been rewritten slightly and issue resolved.:-)
@firemyst
PanagiotisCharalampous
06 May 2020, 08:14
Hi firemyst,
Why do you use DateTime.SpecifyKind() function?
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous