简体   繁体   English

如何在 mql5 中获取明天的日期?

[英]How to get tomorrow date in mql5?

I want to draw a horizontal trendline that extends from today to tomorrow, And I have trouble getting time tomorrow.我想画一条从今天延伸到明天的水平趋势线,而明天我很难抽出时间。

for example today is 2021.12.17 00:00:00例如今天是2021.12.17 00:00:00

Comment( iTime(_Symbol, PERIOD_D1, 0) + (PERIOD_D1*60) );

// Today: 2021.12.17 00:00:00    
// MQL4:  2021.12.18 00:00:00 ... it's ok.
// MQL5:  2021.12.28 09:28:00 ... it's not ok! why?

MQL4 : As you can see in the code above, in mql4, through the iTime function and adding a period, the date of tomorrow can be obtained, it's return 2021.12.18 00:00:00 . MQL4 : 如您在上面的代码中所见,在 mql4 中,通过iTime function 并添加一个句点,可以获得明天的日期,它返回2021.12.18 00:00:00

MQL5 : But this code shows date 2021.12.28 09:28:00 in mql5. MQL5 :但此代码在 mql5 中显示日期2021.12.28 09:28:00 09:28:00。

In other words, PERIOD_D1 is equal to 1440 in mql4 but in mql5 is equal to 16408 , Why?换句话说, PERIOD_D1在 mql4 中等于1440但在 mql5 中等于16408为什么?

Comment(PERIOD_D1);
// MQL4: 1440
// MQL5: 16408 why?!!!

Try this: SELECT DATE_ADD('2018-05-01',INTERVAL 1 DAY);试试这个: SELECT DATE_ADD('2018-05-01',INTERVAL 1 DAY); The function was introduced in MySQL 4.0. function 在 MySQL 4.0 中引入。 Some details are available here: https://www.w3schools.com/sql/func_mysql_date_add.asp .此处提供了一些详细信息: https://www.w3schools.com/sql/func_mysql_date_add.asp

You can also use now() + interval 1 day or curdate() + interval 1 day an answer was available at stackowerflow here: https://stackoverflow.com/a/3887517/5043424您还可以使用now() + interval 1 daycurdate() + interval 1 day ,此处的 stackowerflow 提供了答案: https://stackoverflow.com/a/3887517/5043424

Unlike MQL4, PERIOD_D1 does not relate to the amount of minutes in the period in MQL5.与 MQL4 不同,PERIOD_D1 与 MQL5 中周期中的分钟数无关。 The simple workaround is to add (1440*60) to iTime().简单的解决方法是将 (1440*60) 添加到 iTime()。

Alternatively, use PeriodSeconds() as below或者,使用PeriodSeconds()如下

iTime(_Symbol, PERIOD_D1, 0) + PeriodSeconds(PERIOD_D1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM