But there is the time difference and I want to take that into account automatically.
Future ES Open at 09:30
28.10.2022 in Germany 15:30
04.11.2022 in Germany 14:30
if("02.11.2022 09:30:00" == Time[0].ToString())
{
// Future ES Open at 09:30
// DateTime.Now
// 28.10.2022 in Germany 15:30
// 04.11.2022 in Germany 14:30
Print("Time[0] " + Time[0]);
// TimeZoneInfo.Local (UTC+01:00) Amsterdam, Berlin, Bern, Rom, Stockholm, Wien
Print("TimeZoneInfo.Local " + TimeZoneInfo.Local);
// (UTC-06:00) Central Zeit (USA & Kanada)
Print("Bars.TradingHours.TimeZoneInfo " + Bars.TradingHours.TimeZoneInfo);
DateTime dateTime = Time[0];
Print("TimeZoneInfo.Local.GetUtcOffset(dateTime)" + TimeZoneInfo.Local.GetUtcOffset(dateTime));
// dateTime = dateTime.AddDays(-14);
// dateTime 1 02.11.2022 09:30:00 (correct)
Print("dateTime 1 " + dateTime);
dateTime = dateTime.Add(-Bars.TradingHours.TimeZoneInfo.GetUtcOffset(dateTime));
// dateTime 2 02.11.2022 14:30:00 (correct)
Print("dateTime 2 " + dateTime);
// Test 2
dateTime = Time[0];
// ConvertTime 1 02.11.2022 15:30:00 not right
Print("ConvertTime 1 " + TimeZoneInfo.ConvertTime(dateTime, Bars.TradingHours.TimeZoneInfo, TimeZoneInfo.Local));
}
​
How can I set the right opening time depending on the market. At ES 9:30 correctly in the current time on the chart?
I would appreciate any help or advice.
Comment