Libraries: ConvertServerTime - page 3

 
amrali #:

2020.03.29 01:00 does not exit in EU time

GMT+0 - right.

GMT+2 - wrong.

 
fxsaber #:

GMT+0 - right.

GMT+2 - wrong.

what does this mean?

 
amrali #:

what does this mean?

I don't know why you don't understand.

ERROR: 2025.03.30 01:00 is invalid for DST_EU (DST skipped this hour).

This message is only valid for the GMT+0 time zone. For the broker in the screenshot, this server time exists, as the current time zone is GMT+2.


2025.03.30 01:00 GMT+0 != 2025.03.30 01:00 GMT+2
 
fxsaber #:

I don't know why you don't understand.

This message is only valid for the GMT+0 time zone. For the broker in the screenshot, this server time exists, as the current time zone is GMT+2.


Most brokers on a dst scheduling do not necessarily shift times exactly at Sunday 01:00 am night of the dst switch.

In reality, the dst shift occur at around Sunday 3:00 or 03:03 am, due to various reasons: server implementation, maintenance, operational reasons, or deliberate choice to avoid impact on clients.

For Forex symbols, this has no effect as these times are not trading hours.

For BTCUSD there's a mid-feed split, (the dst shift occurs mid-H1 feed) resulting into two H1 bars (mapped to the same UTC hour) drawn on the chart.The artifact could only be detected on lower timeframe M1 and M5.

Frankly speaking, ConvertServerTime() cannot precisely work (around dst times) on BTCUSD due to that H1-split.

So, accurate time conversions on BTCUSD requires a different approach. (identify time of split point from M1-chart, apply different GMT offsets before/after of the split-point, according to the server's scheduling rule). 

Attached a script to scan M1-timeseries for the splits.
Files:
feed_gaps.mq5  7 kb
 
amrali #:

In reality, the dst shift occur at around Sunday 3:00 or 03:03 am

European countries switch to winter time simultaneously, at the same time. However, their local time differs.

2025.10.25 01:00 UTC+1 == 2025.10.25 02:00 UTC+2 == 2025.10.25 03:00 UTC+3

Brokers quoting in European time specifically try to work in the UTC+3 time zone so that most rollovers throughout the year occur at midnight.

 
fxsaber #:

European countries switch to winter time simultaneously, at the same time. However, their local time differs.

Brokers quoting in European time specifically try to work in the UTC+3 time zone so that most rollovers throughout the year occur at midnight.

Thank you for this information.

I am also posting the table of DST end. https://www.timeanddate.com/news/time/europe-dst-end-2025.html


This makes it clear that servers under european scheduling (DST_EU) work in the Eastern European Time (EET) time zone, UTC+3/+2. 

   if(aRule == DST_EU)
     {
      dst_start = MakeDateTime(iYear, 03, 31 - (4 + Y) % 7, 03);  // the last Sunday of March for the Eastern EU switch (DST+1)
      dst_end   = MakeDateTime(iYear, 10, 31 - (1 + Y) % 7, 04);  // the last Sunday of October for the Eastern EU switch (DST+0)
     }
Europe Ends DST 2024
Europe Ends DST 2024
  • 2025.09.11
  • www.timeanddate.com
Clocks are turned back 1 hour as Daylight Saving Time (DST) ends in Europe on Sunday, October 26, 2025, at 01:00 UTC.
 
amrali #:

This makes it clear that servers under european scheduling (DST_EU) work in the Eastern European Time (EET) time zone, UTC+3/+2. 

European brokers may operate in different time zones, so I suggested doing so.

Forum on trading, automated trading systems and testing trading strategies

Libraries: ConvertServerTime

fxsaber, 2025.10.23 06:20

I may be wrong, but it seems right.

//   const int sourceOffsetDST        = GetDST(aTime, sourceRuleDST);
   const int sourceOffsetDST        = GetDST(aTime - sourceTotalOffset, sourceRuleDST);

And then the corresponding changes.


And this.

      PrintFormat("ERROR: %s is invalid for %s GMT+0 (DST skipped this hour).", TimeToString(aTime), EnumToString(aRule));
 
amrali #:

Attached a script to scan M1-timeseries for the splits.

DST-navigate expert.


Files:
 
fxsaber #:

DST-navigate expert.

With this tool it became immediately possible to write such DST detection logic.

#property script_show_inputs

input string inCryptoSymbol = "BTCUSD";

bool BarIsExist( datetime Time, const string Symb, const ENUM_TIMEFRAMES TF = PERIOD_M15 )
{
  return(iBarShift(Symb, TF ,Time / PeriodSeconds(TF) * PeriodSeconds(TF), true) != -1);
}

void OnStart()
{
  const datetime DateEU = D'2025.03.30';
  const datetime DateUS = D'2024.11.03';
  
  const string CryptoSymbol = (inCryptoSymbol == "") ? _Symbol : inCryptoSymbol;
  
  bool ResEU = false;
  
  for (int i = -10; !ResEU && (i < 10); i++)
    if (ResEU = !BarIsExist(DateEU + 1800 + 3600 * i, CryptoSymbol))
      Print(AccountInfoString(ACCOUNT_SERVER) + ": DST_EUR, GMT" + ((i < 0) ? NULL : "+") + (string)i);

  if (!ResEU)  
    Print(AccountInfoString(ACCOUNT_SERVER) + ": " + (BarIsExist(DateUS, CryptoSymbol) ? "DST_NONE" : "DST_US"));
}


Result.

RannForex-Server: DST_EUR, GMT+3
Exness-MT5Trial3: DST_NONE
FusionMarketsAU-Live: DST_US
 
fxsaber #:

With this tool it became immediately possible to write such DST detection logic.


Result.

Nice tool. I will test it.

Unfortunately, not working on my server.


working: Determine Broker's Daylight (DST) schedule