如果获取当前系统时间与MT4时间差?如何获取真实GMT值?

1732 9
| 发表于 2023-1-8 21:20:39 | 只看该作者 |复制链接
最后由 layy 于 2023-1-8 21:21 编辑

如果获取当前系统时间与MT4时间差?如何获取真实GMT值?
直接上代码:
  1. #import "Kernel32.dll"
  2.    void GetLocalTime(int& a0[]);
  3. #import
  4. // 获取系统时间
  5. datetime GetWindowsSystemTime(){
  6. int TimeArray[4];
  7.    GetLocalTime(TimeArray);
  8.    int year = TimeArray[0] & 65535;
  9.    int month = TimeArray[0] >> 16;
  10.    int day = TimeArray[1] >> 16;
  11.    int hour = TimeArray[2] & 65535;
  12.    int minute = TimeArray[2] >> 16;
  13.    int second = TimeArray[3] & 65535;
  14.    
  15.    return StringToTime( FormatDateTime(year, month, day, hour, minute, second) );
  16. }
  17. // 获取GMT值
  18. int GMTOffset() {  
  19.    double dbDiff = TimeCurrent() - GetWindowsSystemTime();
  20.    return (MathRound(dbDiff / 3600.0));
  21. }
  22. // 格式化时间
  23. string FormatDateTime(int year, int iMonth, int iDay, int iHour, int iMinute, int iSecond) {
  24.    string month = IntegerToString(iMonth + 100);
  25.    month = StringSubstr(month, 1);
  26.    string day = IntegerToString(iDay + 100);
  27.    day = StringSubstr(day, 1);
  28.    string hour = IntegerToString(iHour + 100);
  29.    hour = StringSubstr(hour, 1);
  30.    string minute = IntegerToString(iMinute + 100);
  31.    minute = StringSubstr(minute, 1);
  32.    string second = IntegerToString(iSecond + 100);
  33.    second = StringSubstr(second, 1);
  34.    return StringFormat("%d.%s.%s %s:%s:%s", year, month, day, hour, minute, second);
  35. }
复制代码

举报

收藏 0 点赞 0 评论 使用道具

热门主题

精彩评论9

跳转到指定楼层
ken138888
C
2#
| 发表于 2023-1-10 19:47:24 | 只看该作者
这是mt4还是mt5
举报

点赞 评论 使用道具

ea12213
C
3#
| 发表于 2023-1-11 20:08:17 | 只看该作者
挺有用的
举报

点赞 评论 使用道具

ainibaige
DDD
4#
| 发表于 2023-2-17 10:50:47 | 只看该作者
这是指标还是ea呢?
举报

点赞 评论 使用道具

ainibaige
DDD
5#
| 发表于 2023-2-17 10:54:39 | 只看该作者
放在指标和ea文件里都不行
举报

点赞 评论 使用道具

lyldr
DD
6#
| 发表于 2023-2-21 15:00:32 | 只看该作者
获取真实GMT值
举报

点赞 评论 使用道具

dongxu64
DDD
7#
| 发表于 2023-2-27 08:32:29 | 只看该作者
实用,谢谢楼主。
举报

点赞 评论 使用道具

yuiran
DDD
8#
| 发表于 2023-2-27 11:13:25 | 只看该作者
这个怎么使用?
举报

点赞 评论 使用道具

ken138888
C
9#
| 发表于 2023-3-16 20:43:26 | 只看该作者
有什么用呢?
举报

点赞 评论 使用道具

qwe11
CC
10#
| 发表于 2023-3-16 21:30:44 | 只看该作者
怎么用??
举报

点赞 评论 使用道具

发新帖
EA交易
您需要登录后才可以评论 登录 | 立即注册