//+------------------------------------------------------------------+
//|                                                  HLine Alert.mq4 |
//+------------------------------------------------------------------+
#property copyright "raff1410@o2.pl"

#property indicator_chart_window

extern string info1 = "Fill Price to put line on SetLinePrice";
extern double SetLinePrice= 0;
extern int AlertPipRange=5;
extern bool AlertPush = true;
extern string LineName="MyLine1";
extern color LineColor=clrMagenta; 
extern int LineStyle=STYLE_SOLID;

int multiplier;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   if(Digits == 2 || Digits == 4) multiplier = 1;
   if(Digits == 3 || Digits == 5) multiplier = 10;
   if(Digits == 6) multiplier = 100;   
   if(Digits == 7) multiplier = 1000;   
      
   AlertPipRange*= multiplier;
   
      ObjectCreate(LineName, OBJ_HLINE, 0, 0, SetLinePrice);
      ObjectSet(LineName, OBJPROP_STYLE, LineStyle);
      ObjectSet(LineName, OBJPROP_COLOR, LineColor);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete(LineName);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//--- 
      if(AlertPush){       
      static bool Near = false;
      bool Condition = ((Bid+AlertPipRange*Point >= SetLinePrice)||(Bid-AlertPipRange*Point <= SetLinePrice)); 
      if(!Near && Condition) 
      { 
      PlaySound("Alert.wav");
      SendNotification("HLine Alert on" + _Symbol);
      Alert("Send to Mobile Notification");
      }
      Near = Condition;
      }
            
//----
   return(0);
  }
//+------------------------------------------------------------------+