Simple code request PLEASE!!!

To add comments, please log in or register
palepalepale
122
palepalepale  

So this is what I want to do:


Send a notification to my celphone BUT i only want it to send it maximum once every x time... lets say 1 notification each 12 hours if the condition is true.


Thank you!!!

andrew
405
andrew  
palepalepale:

So this is what I want to do:


Send a notification to my celphone BUT i only want it to send it maximum once every x time... lets say 1 notification each 12 hours if the condition is true.


Thank you!!!

Well, something like this, (not tested)

int next=0;
void sendmsg(){
 if(Hour()==next){
       int i=next;
       bool sent=SendNotification(sometext);
        if(i==0) next=12;
        if(i==12)next=0;   
     }
}
William Roeder
20208
William Roeder  
palepalepale: y 1 notification each 12 hours if the condition is true.
  1. If the condition is false, you want to reset the timer:
    bool condition = …;
    static datetime lastSend=0; if(!condition) lastSend = 0;
    datetime now = TimeCurrent();
    if (now - lastSend >= 12*3600){ lastSend = now; bool sent=SendNotification(sometext); …}

  2. Alternatively, act on a change of signal, so you have only one message.
              MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum #1
palepalepale
122
palepalepale  
William Roeder:
  1. If the condition is false, you want to reset the timer:

  2. Alternatively, act on a change of signal, so you have only one message.
              MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum #1

Brilliant, tyvm

Keith Watford
Moderator
20379
Keith Watford  
palepalepale:

Brilliant, tyvm

Please use English in the forum.

tyvm is not an English word.

Nguyen Van Luong
168
Nguyen Van Luong  
Keith Watford:

Please use English in the forum.

tyvm is not an English word.

tyvm = Thank you very much?
Keith Watford
Moderator
20379
Keith Watford  

Thank you for the definitions.

However that is not my point.

This is an English language forum so please use proper English.

If you are too lazy to type "Thank you very much" then type "thanks".

Remember that a very large proportion of foum members are not native English speakers and terms such as tyvm are meaningless to them.

William Roeder
20208
palepalepale
122
palepalepale  
noted 
palepalepale
122
palepalepale  
William Roeder:
  1. If the condition is false, you want to reset the timer:

  2. Alternatively, act on a change of signal, so you have only one message.
              MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum #1

Is the static variable declared globaly or in the ontick()?

William Roeder
20208
William Roeder  
palepalepale: Is the static variable declared globaly or in the ontick()?
Perhaps you should read the manual.
The scope of the global variables is the same as the scope of the static variables : the lifetime of MQL4 program.
          Global Variables - Variables - Language Basics - MQL4 Reference

The scope of the static variables is the same as the scope of the global variables: the lifetime of the mql4-program.
          Static Variables - Variables - Language Basics - MQL4 Reference

Global or static, both would be redundant.
To add comments, please log in or register