在午夜重置变量
1 頁面的第 562 頁 12 上一個上一個
Results 1 to 10 of 11

Thread: 在午夜重置变量

  1. #1
    我如何在午夜重置var?我的意思是如果在一分钟左右没有蜱虫进入,那么var不会被重置。

    我知道这不是做这件事的权利,但这是我脑子现在可以想到的唯一方式。必须有一个更简单的方法来做到这一点?

    插入代码double DayHigh = 0; double Day2ndHigh = 0; Double DayLow = 0; double Day2ndLow = 0; string time_hours = TimeHour(TimeCurrent()); string time_minutes = TimeMinute(TimeCurrent()); string time_seconds = TimeSeconds(TimeCurrent());如果((time_hours == 00)(time_minutes == 00)(time_seconds == 00)){//重置HighsLows double DayHigh = 0; double Day2ndHigh = 0; Double DayLow = 0; double Day2ndLow = 0; }
    它可以不依靠滴答作出?

  2. #2

    Quote Originally Posted by ;
    {quote}是的


  3. #3

    Quote Originally Posted by ;
    我如何在午夜重置var?我的意思是如果在一分钟左右没有蜱虫进入,那么var不会被重置。我知道这不是做这件事的权利,但这是我脑子现在可以想到的唯一方式。必须有一个更简单的方法来做到这一点? Double DayHigh = 0; double Day2ndHigh = 0; Double DayLow = 0; double Day2ndLow = 0; string time_hours = TimeHour(TimeCurrent()); string time_minutes = TimeMinute(TimeCurrent()); string time_seconds = TimeSeconds(TimeCurrent()); if((time_hours == 00)(time_minutes == 00)(time_seconds == 00)){...
    是的,你需要使用OnTimer()函数。你也会想要避免绝对;就像秒数等于零一样,因为你可能会错过第二个完全为零的窗口,然后你的代码就无法工作。插入代码int OnInit(){//--- create timer EventSetTimer(1);/--- return(INIT_SUCCEEDED); }/ ---------------------------------------------- -------------------- /|专家解除初始化函数|/ ----------------------------------------------- ------------------- void OnDeinit(const int reason){//--- destroy timer EventKillTimer(); }/ ---------------------------------------------- -------------------- /|专家打勾功能|/ ----------------------------------------------- ------------------- void OnTick(){//---}/ ---------------- -------------------------------------------------- /|定时器功能|/ ----------------------------------------------- ------------------- void OnTimer(){//--- ResetVarsAtMidnight(); }/ ---------------------------------------------- -------------------- double DayHigh = 0; double Day2ndHigh = 0; Double DayLow = 0; double Day2ndLow = 0; void ResetVarsAtMidnight(){static datetime last_reset = 0; MqlDateTime last_reset_struct; if(last_reset == 0 || TimeCurrent()gt; = last_reset PeriodSeconds(PERIOD_D1)){//重置HighsLows DayHigh = 0; Day2ndHigh = 0; DayLow = 0; Day2ndLow = 0; TimeCurrent(last_reset_struct); last_reset_struct.hour = 0; last_reset_struct.min = 0; last_reset_struct.sec = 0; last_reset = StructToTime(last_reset_struct);返回; }}

  4. #4

    Quote Originally Posted by ;
    {quote}是的,你需要使用OnTimer()函数。你也会想要避免绝对;就像秒数等于零一样,因为你可能会错过第二个完全为零的窗口,然后你的代码就无法工作。 int OnInit(){//--- create timer EventSetTimer(1);/--- return(INIT_SUCCEEDED); }/ ---------------------------------------------- -------------------- /|专家解除初始化函数|/ ----------------------------------------------- ------------------- void OnDeinit(const int reason){//---销毁计时器...
    感谢您的代码示例!我应该不能通过设置它来测试它:last_reset_struct.hour = 20; last_reset_struct.min = 40; last_reset_struct.sec = 00;如果是这样,它不会将变量设置为0。

  5. #5
    这应该每天20点40分复位

  6. #6

    Quote Originally Posted by ;
    这应该每天20点40分复位
    是的,但它不会重置该变种

  7. #7

    Quote Originally Posted by ;
    {quote}是的,但它不重置var的
    因为它不会在初始化后的第二天重置。如果你希望它能够做到,那么你需要添加一些初始化逻辑并将它初始化到前一天。插入代码int OnInit(){//--- create timer EventSetTimer(1);/--- return(INIT_SUCCEEDED); }/ ---------------------------------------------- -------------------- /|专家解除初始化函数|/ ----------------------------------------------- ------------------- void OnDeinit(const int reason){//--- destroy timer EventKillTimer(); }/ ---------------------------------------------- -------------------- /|专家打勾功能|/ ----------------------------------------------- ------------------- void OnTick(){//---}/ ---------------- -------------------------------------------------- /|定时器功能|/ ----------------------------------------------- ------------------- void OnTimer(){//--- ResetVarsAtMidnight(); }/ ---------------------------------------------- -------------------- double DayHigh = 0; double Day2ndHigh = 0; Double DayLow = 0; double Day2ndLow = 0; void ResetVarsAtMidnight(){MqlDateTime last_reset_struct; static datetime last_reset = TimeCurrent(); static bool is_init = false; int hour = 0; int min = 0; int sec = 0; if(!is_init){last_reset- = PeriodSeconds(PERIOD_D1); TimeToStruct(last_reset,last_reset_struct); last_reset_struct.hour =小时; last_reset_struct.min = min; last_reset_struct.sec = sec; last_reset = StructToTime(last_reset_struct); is_init = true; } if(TimeCurrent()gt; = last_reset PeriodSeconds(PERIOD_D1)){//重置HighsLows DayHigh = 0; Day2ndHigh = 0; DayLow = 0; Day2ndLow = 0; TimeCurrent(last_reset_struct); last_reset_struct.hour =小时; last_reset_struct.min = min; last_reset_struct.sec = sec; last_reset = StructToTime(last_reset_struct);返回; }}

  8. #8

    Quote Originally Posted by ;
    {quote}因为它不会在初始化后的第二天重置。如果你希望它能够做到,那么你需要添加一些初始化逻辑并将它初始化到前一天。 int OnInit(){//--- create timer EventSetTimer(1);/--- return(INIT_SUCCEEDED); }/ ---------------------------------------------- -------------------- /|专家解除初始化函数|/ ----------------------------------------------- ------------------- void OnDeinit(const int reason){//---销毁计时器EventKillTimer(); ...
    我试图看看它是否有效,但我看不到var在例如零。 21:10:00,为什么?插入的代码// --------------------------------------------- --------------------- /| Test.mq4 |/|版权所有2017,MetaQuotes Software Corp. |/| https://www.mql5.com |/ ----------------------------------------------- ------------------- #属性版权版权2017,MetaQuotes Software Corp.#属性链接https://www.mql5.com #property版本1.00 #property strict int OnInit(){//--- create timer EventSetTimer(1);/--- return(INIT_SUCCEEDED); }/ ---------------------------------------------- -------------------- /|专家解除初始化函数|/ ----------------------------------------------- ------------------- void OnDeinit(const int reason){//--- destroy timer EventKillTimer(); }/ ---------------------------------------------- -------------------- /|专家打勾功能|/ ----------------------------------------------- ------------------- void OnTick(){DayHigh = High#91; 1#93 ;; Day2ndHigh =高#91; 2#93 ;; DayLow =低#91; 1#93 ;; Day2ndLow =低#91; 2#93 ;;评论(High_1: DayHigh High_2: Day2ndHigh Low_1: DayLow Low_2: Day2ndLow); }/ ---------------------------------------------- -------------------- /|定时器功能|/ ----------------------------------------------- ------------------- void OnTimer(){//--- ResetVarsAtMidnight(); }/ ---------------------------------------------- -------------------- double DayHigh = 0; double Day2ndHigh = 0; Double DayLow = 0; double Day2ndLow = 0; void ResetVarsAtMidnight(){MqlDateTime last_reset_struct; static datetime last_reset = TimeCurrent(); static bool is_init = false; int hour = 21; int min = 10; int sec = 0; if(!is_init){last_reset- = PeriodSeconds(PERIOD_D1); TimeToStruct(last_reset,last_reset_struct); last_reset_struct.hour =小时; last_reset_struct.min = min; last_reset_struct.sec = sec; last_reset = StructToTime(last_reset_struct); is_init = true; } if(TimeCurrent()gt; = last_reset PeriodSeconds(PERIOD_D1)){//重置HighsLows DayHigh = 0; Day2ndHigh = 0; DayLow = 0; Day2ndLow = 0; TimeCurrent(last_reset_struct); last_reset_struct.hour =小时; last_reset_struct.min = min; last_reset_struct.sec = sec; last_reset = StructToTime(last_reset_struct);返回; }}

  9. #9

    Quote Originally Posted by ;
    {quote}我试图看看它是否有效,但我无法看到var在例如0处被设置为零。 21:10:00,为什么?/ ----------------------------------------------- ------------------- /| Test.mq4 |/|版权所有2017,MetaQuotes Software Corp. |/|
    https://www.mql5.com|/ ----------------------------------------------- ------------------- #属性版权版权2017,MetaQuotes Software Corp.#属性链接https://www.mql5.com #property版本1.00 #property strict int OnInit(){//--- create timer EventSetTimer(1);/--- return(INIT_SUCCEEDED); ...
    有用。你的代码永远不会显示给你。尝试这个。插入的代码// --------------------------------------------- --------------------- /| DailyVarReset.mq4 |/|版权2017,nicholishen |/| https://www.forex-pedia.com/nicholishen |/ ----------------------------------------------- ------------------- #property copyright版权2017,nicholishen#房源链接https://www.forex-pedia.com/nicholishen/ ------ -------------------------------------------------- ---------- /| Test.mq4 |/|版权所有2017,MetaQuotes Software Corp. |/| https://www.mql5.com |/ ----------------------------------------------- ------------------- #属性版权版权2017,MetaQuotes Software Corp.#属性链接https://www.mql5.com #property版本1.00 #property strict int OnInit(){//--- create timer EventSetTimer(1);/--- return(INIT_SUCCEEDED); }/ ---------------------------------------------- -------------------- /|专家解除初始化函数|/ ----------------------------------------------- ------------------- void OnDeinit(const int reason){//--- destroy timer EventKillTimer(); }/ ---------------------------------------------- -------------------- /|专家打勾功能|/ ----------------------------------------------- ------------------- void OnTick(){//DayHigh = High#91; 1#93 ;;/Day2ndHigh = High#91; 2#93 ;;/DayLow =低#91; 1#93 ;;/Day2ndLow =低#91; 2#93 ;;/评论(High_1: DayHigh High_2: Day2ndHigh Low_1: DayLow Low_2: Day2ndLow); }/ ---------------------------------------------- -------------------- /|定时器功能|/ ----------------------------------------------- ------------------- void OnTimer(){//--- ResetVarsAtMidnight(); }/ ---------------------------------------------- -------------------- double DayHigh = 0; double Day2ndHigh = 0; Double DayLow = 0; double Day2ndLow = 0; void ResetVarsAtMidnight(){MqlDateTime last_reset_struct; static datetime last_reset = TimeCurrent(); static bool is_init = false; int hour = 18; int min = 56; int sec = 0; if(!is_init){last_reset- = PeriodSeconds(PERIOD_D1); TimeToStruct(last_reset,last_reset_struct); last_reset_struct.hour =小时; last_reset_struct.min = min; last_reset_struct.sec = sec; last_reset = StructToTime(last_reset_struct); is_init = true; } if(TimeCurrent()gt; = last_reset PeriodSeconds(PERIOD_D1)){//重置HighsLows DayHigh = 0; Day2ndHigh = 0; DayLow = 0; Day2ndLow = 0;警报(Resting vars!);**********TimeCurrent(last_reset_struct); last_reset_struct.hour =小时; last_reset_struct.min = min; last_reset_struct.sec = sec; last_reset = StructToTime(last_reset_struct);返回; }}

  10. #10

    Quote Originally Posted by ;
    {quote}它的工作原理。你的代码永远不会显示给你。尝试这个。/ ----------------------------------------------- ------------------- /| DailyVarReset.mq4 |/|版权2017,nicholishen |/|
    https://www.forex-pedia.com/forex-ma...e-journal.html|/ ----------------------------------------------- ------------------- #property copyright版权2017,nicholishen#房源链接https://www.forex-pedia.com/nicholishen/ ------ -------------------------------------------------- ---------- /| Test.mq4 |/|版权所有2017,MetaQuotes Software Corp ....
    它工作得非常好谢谢你的代码和你的帮助!我只是好奇,如果我需要一个好的编码器,你可以雇用吗?

發布權限

  • 您不可發布新主題
  • 您不可回复
  • 您不可發布附件
  • 您不可編輯您的帖子
  •  
  • BB代碼是打開的
  • 表情符號是打開的
  • [IMG]代碼是打開的
  • [視頻]代碼是打開的
  • HTML代碼是關閉的
forex-pedia網站使用cookie 文字跟蹤
forex-pedia.com網站使用cookie 文字跟蹤,某些設定已經固定。您可以點擊此處閱讀我們的Cookie使用說明。 請點擊右鍵接受我們的cookies。如果您選擇繼續使用forex-pedia.com網站,我們將認為您接受我們的cookies。