Download MetaTrader 5
To add comments, please log in or register
Do you want to write a trading robot? Find solution in MQL5 Reference!
redwind
9
redwind 2014.09.27 00:52 

Hi all,

 

This is the simple program i write, but it will give more than one alert in one time.

 

can some one help on that, how to make it give only one alert each time.

 

Thank you

 

 


 datetime  TimeCurrent();

 datetime b= D'13:59:00';

 datetime a= D'13:59:30';

  int abc =1;

  int bcd =2;

int start()                                // Special function start() 

 {

if( b == TimeCurrent()&&j<1)

{

 Alert(abc);

if( a == TimeCurrent())

{

Alert(bcd);

}

return;                                 // Exit start()  

}

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.09.27 00:59  
whroeder1
13627
whroeder1 2014.09.27 13:21  
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2.  datetime b= D'13:59:00';
     datetime a= D'13:59:30';
    These are 1:59 PM of the date you compiled the code. Don't expect more than two alerts ever.
    #define HR2400 (PERIOD_D1 * 60)  // 86400 = 24 * 3600
    int      TimeOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();
                                              return( when % HR2400 );            }
    datetime DateOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();
                                              return( when - TimeOfDay(when) );   }
    datetime Tomorrow( datetime when=0){      if(when == 0)  when = TimeCurrent();
                                              return(DateOfDay(when) + HR2400);   }
    //datetime Yesterday(datetime when=0){      if(when == 0)  when = TimeCurrent();
    //   int iD1 = iBarShift(NULL, PERIOD_D1, DateOfDay(when) - 1);
    //                                       return( iTime(NULL, PERIOD_D1, iD1) ); }
    
    OnIinit(){
       #define HR1359 49800     // (13*60+59)*60
       a = Tomorrow() + HR1359; // 13:59:00
       b = a + 30;              // 13:59:30
  3. if( a == TimeCurrent())
    This matches only if a tick occurred on the exact second. One second later - no alert. Multiple ticks that second, multiple alerts.
  4. redwind: can some one help on that, how to make it give only one alert each time.
    if( a != 0 && a <= TimeCurrent()){
       Alert(bcd);
       a = 0; // Suppress additional alerts
    if(a <= TimeCurrent()){
       Alert(bcd); #define HR2400 86400 // 24 * 60 * 60
       a += HR2400; // Next alert is tomorrow
/
To add comments, please log in or register