Bug in cTrader Algo regarding times at chart??

Created at 08 Oct 2024, 13:22
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!
CT

ctid6435772

Joined 14.08.2024

Bug in cTrader Algo regarding times at chart??
08 Oct 2024, 13:22


Hello,

I had correct times in my exchanges “keytimes” algo.

London & Tokyo are correct - but Sydney & NY times are shown incorrect at chart.

Why this happen?

using System;using cAlgo.API;using cAlgo.API.Collections;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo{    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]    public class KeyTimes : Indicator    {        protected override void Initialize()        {            // Initialization logic if needed        }        public override void Calculate(int index)        {            // Convert times to the user's time zone (Europe/Berlin)            DateTime utcTime = Bars.OpenTimes[index];            TimeZoneInfo berlinTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Europe/Berlin");            DateTime berlinTime = TimeZoneInfo.ConvertTime(utcTime, berlinTimeZone);            // Check if Daylight Saving Time is in effect            bool isDaylight = berlinTimeZone.IsDaylightSavingTime(berlinTime);            // Calculate the NY Killzone and NY Open Time based on daylight saving time            int nyKillzoneHour = isDaylight ? 13 : 12;  // Summer (DST): 13:00, Winter: 12:00            int nyOpenTimeHour = isDaylight ? 14 : 13;  // Summer (DST): 14:00, Winter: 13:00            // London Session            if (berlinTime.Hour == 8 && berlinTime.Minute == 0) // London Killzone in Berlin time            {                Chart.DrawVerticalLine(index.ToString() + "LondonKillzone", index, "orange");                Chart.DrawText("LondonKillzone" + index.ToString(), "London Killzone", index, Bars.ClosePrices[index] + 20 * Symbol.PipSize, "orange");            }            if (berlinTime.Hour == 9 && berlinTime.Minute == 0) // London Open in Berlin time            {                Chart.DrawVerticalLine(index.ToString() + "LondonOpen", index, "black");                Chart.DrawText("LondonOpen" + index.ToString(), "London Open", index, Bars.ClosePrices[index], "black");            }            // New York Session            if (berlinTime.Hour == nyKillzoneHour && berlinTime.Minute == 0) // NY Killzone in Berlin time            {                Chart.DrawVerticalLine(index.ToString() + "NYKillzone", index, "orange");                Chart.DrawText("NYKillzone" + index.ToString(), "NY Killzone", index, Bars.ClosePrices[index] + 20 * Symbol.PipSize, "orange");            }            if (berlinTime.Hour == nyOpenTimeHour && berlinTime.Minute == 0) // NY Open in Berlin time            {                Chart.DrawVerticalLine(index.ToString() + "NYOpen", index, "black");                Chart.DrawText("NYOpen" + index.ToString(), "NY Open", index, Bars.ClosePrices[index], "black");            }            // Tokyo Session            if (berlinTime.Hour == 1 && berlinTime.Minute == 0) // Tokyo Killzone in Berlin time            {                Chart.DrawVerticalLine(index.ToString() + "TokyoKillzone", index, "orange");                Chart.DrawText("TokyoKillzone" + index.ToString(), "Tokyo Killzone", index, Bars.ClosePrices[index] + 20 * Symbol.PipSize, "orange");            }            if (berlinTime.Hour == 2 && berlinTime.Minute == 0) // Tokyo Open in Berlin time            {                Chart.DrawVerticalLine(index.ToString() + "TokyoOpen", index, "black");                Chart.DrawText("TokyoOpen" + index.ToString(), "Tokyo Open", index, Bars.ClosePrices[index], "black");            }            // Sydney Session            if (berlinTime.Hour == 1 && berlinTime.Minute == 0) // Sydney Killzone in Berlin time            {                Chart.DrawVerticalLine(index.ToString() + "SydneyKillzone", index, "orange");                Chart.DrawText("SydneyKillzone" + index.ToString(), "Sydney Killzone", index, Bars.ClosePrices[index] + 20 * Symbol.PipSize, "orange");            }            if (berlinTime.Hour == 2 && berlinTime.Minute == 0) // Sydney Open in Berlin time            {                Chart.DrawVerticalLine(index.ToString() + "SydneyOpen", index, "black");                Chart.DrawText("SydneyOpen" + index.ToString(), "Sydney Open", index, Bars.ClosePrices[index], "black");            }        }    }}

@ctid6435772
Replies

PanagiotisCharalampous
09 Oct 2024, 05:23

Hi there,

Please provide the code in a proper format so that we can easily copy/paste it and build it.

Best regards,

Panagiotis


@PanagiotisCharalampous