Since the end of the FX session was determined in this way, among other things, in order to determine the offset of the broker time, this now results in incorrect values!
This calculation has been changed in v. 2.03. But also the calculation of the time changes was changed altogether, so that now also the complicated times of the time change from Sydney (Australia) back to the 70’s are covered.
Attached is also the table DST 1975 – 2030.xlsx as zip-file with all time changes since the 70’s in a way that everybody can check the correct working of the formulas, here a sample series of the table:
On 01/01/1982 it is wintertime in the USA (DST==0) and the next changeover is on 04/25/1982, which is the last (25th of the month) Sunday of April (4). The table is already sorted by the geographic time zone (column A), then by the time zone of the year (column L, spr=spring, aut=autumn,), and finally by the query date (column C). The table can be created automatically by the included EA (a script cannot run in debug mode) Test_DST 2.mq5 if you run it in debug mode and copy the rows of the journal log in the debugger and paste them into a table program; the cell separator would be the space character.
Also, there is now a new, simple function SecTillClose() that gives you the remaining time in seconds (the time currency of MQ) until the forex market will close – without CopyTime(). This is interesting for those who want to close their positions before the weekend or do not want to enter a new position in a defined period of time before the weekend.
The included indicator DealingWithTime_TestIndi.mq5 shows as a comment on the chart not only the summer/winter time of Europe, USA and Australia (Sydney), but also current time and time shift of different cities. Here you can find a table of different local times of big cities for your comparison:
The last two lines also show the last second of the current FX session and the remaining time in hours (is easier to judge) and in seconds. If in NY on Fridays at 17:00 local time the FX session is closed, then there is no valid bar with an opening time 17:00 NY time. Therefore, 1 second is subtracted in this function to be able to get the last valid opening time of the last bar in the broker’s time. However, some brokers end their FX session a few minutes earlier by not providing any more prices and not accepting any more trade orders.