Just a guess: try to disable the visual mode and/or choose real ticks.
Unfortunately... :( Neither disabling visual mode or choosing real ticks helps.
I also switched to a live account on the same provider (I was on demo) but didn't help.
After searching for a long time I discovered that the error arrives in that command:
datetime tGMT = ::TimeGMT();
second command in the `SetLocalTime`.
Strangely enough, the TimeGMT() method returns a strange date (a week later) even though no ticks have arrived inside the expert (I have breakpoint to be sure) and we are still inside the OnInit().
intOnInit()
{
//---Print("\n========== Working with FTSE session hours ==========");
const ENUM_ZONE_ID FTSE_zone_id = ZONE_ID_LONDON;
CSessionHours FTSE_tz(FTSE_zone_id); <--------------- Here
Further more, when I comment out the `CheckLoadHistory(symbol, PERIOD_H1);` inside the `string CTimeZoneInfo::FindSymbol(string symbol)` method it returns correct values.
Not sure of what could affect the ::TimeGMT() method inside the CheckLoadHistory but I will continue investigating it and inform you about my findings.
In any case I don't believe that the TimeGMT should return different date on subsequent call unless new ticks arrive. As such I am thinking that Metatrader has some kind of bugs...
Hi Amrali Thanks for this excelant piece of code. I think the DST start and end is swapped on Sydney though. They do have DST now.
Please confirm again on the mentioned website.
Together we always help each other.
Keep up the good work ... case ZONE_ID_SYDNEY: /// /// Sydney: https://www.timeanddate.com/time/change/australia/sydney /// DST begins at 03:00 local time on the first Sunday of April (-1), /// and ending at 02:00 local time on the first Sunday of October (+1) /// dst_start = Date(iYear, 04, (7 - (4 + Y) % 7), 03, 00); dst_end = Date(iYear, 10, (7 - (5 + Y) % 7), 02, 00);
It doesn't work correctly. I have to make further adjustments to get it to work with London/NY/Tokyo on the same chart. Here is the code that works for me:
It doesn't work correctly. I have to make further adjustments to get it to work with London/NY/Tokyo on the same chart. Here is the code that works for me:
You can simplify the above code to convert chart's bar times to another timezone:
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Just a guess: try to disable the visual mode and/or choose real ticks.
Unfortunately... :( Neither disabling visual mode or choosing real ticks helps.
I also switched to a live account on the same provider (I was on demo) but didn't help.
After searching for a long time I discovered that the error arrives in that command:
second command in the `SetLocalTime`.
Strangely enough, the TimeGMT() method returns a strange date (a week later) even though no ticks have arrived inside the expert (I have breakpoint to be sure) and we are still inside the OnInit().
Further more, when I comment out the `CheckLoadHistory(symbol, PERIOD_H1);` inside the `string CTimeZoneInfo::FindSymbol(string symbol)` method it returns correct values.
Not sure of what could affect the ::TimeGMT() method inside the CheckLoadHistory but I will continue investigating it and inform you about my findings.
In any case I don't believe that the TimeGMT should return different date on subsequent call unless new ticks arrive. As such I am thinking that Metatrader has some kind of bugs...
Latest findings...
There is definitely an issue with the `Sleep` method inside the `CheckLoadHistory`.
If I change it to something like:
I see the TimeLocal() switching by 5 seconds.
The problem becomes worse if I change it to:
The more loops using GetTickCount() and Sleep() and becomes worse.
Inside the `CheckLoadHistory` it has the following loop which is the one that creates the issue.
Did something change in the later versions of Metatrader?
Removing the Sleep statement as bellow it fixes the problem and returns correct day.
There is definitely an issue with the `Sleep` method inside the `CheckLoadHistory`.
Fixed in v2.17.
Thanks @Efthymios Kalyviotis and @Rob Josephus Maria Janssen for detecting this bug.
It doesn't work correctly. I have to make further adjustments to get it to work with London/NY/Tokyo on the same chart. Here is the code that works for me:
It doesn't work correctly. I have to make further adjustments to get it to work with London/NY/Tokyo on the same chart. Here is the code that works for me:
You can simplify the above code to convert chart's bar times to another timezone:
datetime zoneBarTime = CTimeZoneInfo::ConvertTimeForPlace(barTime, ZONE_ID_BROKER, TargetTimeZone);