Correct Way of Using IsDaylightSavingTime()

Created at 23 Jul 2018, 20:33
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
12

1222Ht

Joined 11.11.2017

Correct Way of Using IsDaylightSavingTime()
23 Jul 2018, 20:33


Hi, Thank you for reading my question 

I notice that between March and November , the time is different by an hour , that totally mess up my indicator where i rely on MarketSeries.OpenTime.LastValue.TimeOfDay.TotalMinutes,  (on 2Hour Time Frame) 

 

I tried this :

         private double Total_Minutes;
        public override void Calculate(int index)
        {
            Total_Minutes = MarketSeries.OpenTime.LastValue.TimeOfDay.TotalMinutes;
            if (MarketSeries.OpenTime.LastValue.IsDaylightSavingTime())
                Total_Minutes = MarketSeries.OpenTime.LastValue.TimeOfDay.TotalMinutes - 60;

            ChartObjects.DrawText(index.ToString(), Total_Minutes.ToString(), index, MarketSeries.Low[index], VerticalAlignment.Bottom, HorizontalAlignment.Center);
        }

 

but it somehow doesnt work . I realize that there are a few ways to use IsDayLightSavingTime() , eg  Server.Time.IsDaylightSavingTime() , and i wonder have i used it incorrectly 

Thank you very much


@1222Ht
Replies

1222Ht
24 Jul 2018, 06:59

I find a way that seems to work but not knowing if thats the right way ...

 

    Minutes_In_Day = MarketSeries.OpenTime.LastValue.TimeOfDay.TotalMinutes;
       
                    DateTime TZI = TimeZoneInfo.ConvertTime(MarketSeries.OpenTime.LastValue, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
                    if (TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time").IsDaylightSavingTime(TZI))
                        Minutes_In_Day = MarketSeries.OpenTime.LastValue.TimeOfDay.TotalMinutes - 60;

Thank you very much for reading my question and if provides a solution ....


@1222Ht