Download MetaTrader 5
To add comments, please log in or register
Download MQL5 library codes via MetaTrader. It is convenient!
Akshay
48
Akshay 2015.10.13 10:26 
//+------------------------------------------------------------------+
//|                                                   Time Alert.mq4 |
//|                                                      Akshay Jain |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Akshay Jain"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict


extern double Alert_Time_1 = 19.30;
input string MSG1 = "Hi, type you msg here";
input double Alert_Time_2 =12.30;
extern string MSG2 = "Hi, type you msg here";
bool   T1 = false;
bool   T2 = false;
input double High_Alert  = 100000;
input double Low_Alert  = 0;
bool SP1 = false;
bool SP2 = false;
//--------------------------------------------------------------- 2 --
int start()                            // Spec. start function
  {
  int    Cur_Hour=Hour();             // Server time in hours
   double Cur_Min =Minute();           // Server time in minutes
   double Cur_time=Cur_Hour + Cur_Min; 
 
  
   if (Cur_time >(Alert_Time_1 - 0.30) && T1 == false)             // If the time for the event has come
  
   {
    Alert(MSG1);
    string subject   = (MSG1);
    string some_text = "";
    SendMail( subject,  some_text);
    PlaySound("PriceAlert.wav");   
    SendNotification (MSG1);
   T1 = true;
   }
  
   
   if (Cur_time>(Alert_Time_2 - 0.30) && T2 == false)             // If the time for the event has come
 
   {
      Alert(MSG2);
     string subject   = (MSG2);
     string some_text = "";
     SendMail( subject,  some_text);
     PlaySound("PriceAlert.wav");
     SendNotification (MSG2);
   T2 = true;
   }
    
    
    if (Bid >= High_Alert && SP1 == false)
{
Alert(Symbol()," High_Alert at ", DoubleToStr(High_Alert) ," is complete at " ,TimeToStr(TimeLocal(),TIME_SECONDS));
   string subject   = (Symbol()+ " High_Alert at " + DoubleToStr(High_Alert) + " is complete at " + TimeToStr(TimeLocal(),TIME_SECONDS));
   string some_text = "";
   SendMail( subject,  some_text);
      PlaySound("PriceAlert.wav");   
   SP1 = true;
}
    
      if (Bid <= Low_Alert && SP2 == false)
{
Alert(Symbol()," Low_Alert at ", DoubleToStr(Low_Alert) ," is complete at " ,TimeToStr(TimeLocal(),TIME_SECONDS));
   string subject   = (Symbol()+ " Low_Alert at " + DoubleToStr(Low_Alert) + " is complete at " + TimeToStr(TimeLocal(),TIME_SECONDS));
   string some_text = "";
   SendMail( subject,  some_text);
      PlaySound("PriceAlert.wav");   
   SP2 = true;
}
    
  
   return(0);                             // Exit from start()
}
/
To add comments, please log in or register