How sure are you that your GMT_Time is being calculated correctly?
According to you formula, the GMT_StartHH & GMT_StartMM are constants, so they cannot change, therefore by definition in your formula, the GMT_Time is the problem.
Off the top of my head I would suggest that your GMT_Offset is being calculated according to the TimeLocal() of your VPS/PC rather than the TimeCurrent() of your broker.
How sure are you that your GMT_Time is being calculated correctly?
According to you formula, the GMT_StartHH & GMT_StartMM are constants, so they cannot change, therefore by definition in your formula, the GMT_Time is the problem.
Off the top of my head I would suggest that your GMT_Offset is being calculated according to the TimeLocal() of your VPS/PC rather than the TimeCurrent() of your broker.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I've got a little snippet of code that works fine on my home PC at multiple brokers but fails on my forex.com VPS. External variables are defined as follows:
extern int GMT_StartHH = 11; // GMT Hour to start trading
extern int GMT_StartMM = 00; // GMT Minute to start trading
extern int GMT_EndHH = 02; // GMT Hour to stop trading
extern int GMT_EndMM = 00; // GMT Minute to stop trading
Code in the function:
datetime GMT_Time, TimeStart, TimeEnd;
GMT_Time = Time[0] - (GMT_Offset * 3600);
TimeStart = StrToTime(TimeToStr(GMT_Time, TIME_DATE) + " 00:00") + (GMT_StartHH * 3600) + (GMT_StartMM * 60);
TimeEnd = StrToTime(TimeToStr(GMT_Time, TIME_DATE) + " 00:00") + (GMT_EndHH * 3600) + (GMT_EndMM * 60);
The GMT_Time is calculated correctly, yet the VPS adds five hours to TimeStart and TimeEnd (Print statements show start as 16 and end as 7). Before I start pulling hair out over this, does anyone see a problem with the code or know of something on the VPS that would cause the problem? Using Build 225 of MT4 on VPS, works fine on 225 and 226 on home PC.
Thanks!