Navigation´╝ÜHome > Content >

HLine_Alert_once_per_bar.mq4

Time: 2011-03-28 | Download file:HLine_Alert_once_per_bar.mq4

//+------------------------------------------------------------------+
//|                                                  HLine Alert.mq4 |
//+------------------------------------------------------------------+
#property copyright "raff1410@o2.pl"

//Alert once per bar added by Jack Hewings


#property indicator_chart_window
extern string LineName="MyLine1";
extern color LineColor=AliceBlue; 
extern int LineStyle=STYLE_SOLID;
extern int AlertPipRange=1;
extern string AlertWav="alert.wav";
extern string Subject = "level 0";
extern string message = "level 0 reached";



//jjj
int LastAlert=0;

int NewAlert=0;





//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators


//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
    
      ObjectCreate(LineName, OBJ_HLINE, 0, 0, Bid);
      ObjectSet(LineName, OBJPROP_STYLE, LineStyle);
      ObjectSet(LineName, OBJPROP_COLOR, LineColor);
      NewAlert = 0;
      double val =  ObjectGet( LineName, OBJPROP_PRICE1);
      
      
      
      
      if (Bid-AlertPipRange*Point <= val && Bid+AlertPipRange*Point >= val) NewAlert=1;

    

      if ( NewAlert==1)
        {
            
          if (LastAlert == 0 || LastAlert < Bars )
            {
            
            PlaySound(AlertWav);
            LastAlert = Bars;
       
             }
         }         





//----
//----
   return(0);
    }
//+------------------------------------------------------------------+

Recommend