//+------------------------------------------------------------------+
//|                                                  HLine Alert.mq4 |
//+------------------------------------------------------------------+
#property copyright "raff1410@o2.pl"

#property indicator_chart_window
extern string LineName="MyLineL";
extern string LineName1="MyLineH";
extern color LineColor=Pink; 
extern color LineColor1=DodgerBlue; 
extern int LineStyle=STYLE_SOLID;
extern int LineStyle1=STYLE_SOLID;
extern int pipDistance = 200;
extern string AlertWav="alert.wav";

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
 ObjectsDeleteAll();
// ObjectsDeleteAll(0, OBJ_LABEL);  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
    
    double Opend     = iOpen(Symbol(), PERIOD_D1,0);
          if (MarketInfo(Symbol() ,MODE_DIGITS) == 4 || MarketInfo(Symbol() ,MODE_DIGITS) == 2) {
      double   PairPip = MarketInfo(Symbol() ,MODE_POINT);
      double   pipsfactor = 1;
      } else { 
         PairPip = MarketInfo(Symbol() ,MODE_POINT)*10;
         pipsfactor = 10;
}
      ObjectCreate(LineName, OBJ_HLINE, 0, 0, Opend - pipDistance*PairPip);
      ObjectSet(LineName, OBJPROP_STYLE, LineStyle);
      ObjectSet(LineName, OBJPROP_COLOR, LineColor);
     
      ObjectCreate(LineName1, OBJ_HLINE, 0, 0, Opend + pipDistance*PairPip);
      ObjectSet(LineName1, OBJPROP_STYLE, LineStyle1);
      ObjectSet(LineName1, OBJPROP_COLOR, LineColor1);
        
      double val =  ObjectGet( LineName, OBJPROP_PRICE1);
      if (Bid <= val ) PlaySound(AlertWav);
      
      double val1 =  ObjectGet( LineName1, OBJPROP_PRICE1);
      if (Bid >= val1 ) PlaySound(AlertWav);








//----
//----
   return(0);
  }
//+------------------------------------------------------------------+