qsxyj





//+------------------------------------------------------------------+
//|                                                         qsxyj.mq4 |
//|                       Copyright ?2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "WYF - Trendline break alert"
#property link      "http://www.metaquotes.net"

#property indicator_chart_window

extern bool AllowSound=1;  
extern bool AllowAlertWindow=0;
extern int AlertInterval_Minute=15;
extern int KeepText_Minute=10;

extern string linename="Tr"; 


int PrevAlertTime = 0; 
int Prevtext=0;

int init()
  {
   return(0);
  }
  
int deinit()
  {
   Comment(" ");
   if(ObjectFind("tpl")==0) ObjectDelete("tpl");   
   return(0);
  }                            
//+------------------------------------------------------------------+
int start()
  { 
   int    j,yjx=0;
   double price1,dh,dl,price0;
   string name1;
   
        
   if(AllowSound) Comment("WYF - Trendline break alert: Sound On");
     else Comment("WYF - Trendline break alert: Sound Off")  ;   


//------------find all trendlines and alert----------------------------------------------------------------------
   for (j=0; j<ObjectsTotal(); j++)
    {if(StringSubstr(ObjectName(j),0,2)==linename && ObjectType(ObjectName(j))==OBJ_TREND) 
       { 
         yjx=1; 
         price1=NormalizeDouble(ObjectGetValueByShift(ObjectName(j),1),
                 MarketInfo(Symbol(),MODE_DIGITS)); 
         price0=NormalizeDouble(ObjectGetValueByShift(ObjectName(j),0),
                 MarketInfo(Symbol(),MODE_DIGITS));        
                 
         if (TimeCurrent()-PrevAlertTime>AlertInterval_Minute*60)
           {
            if (Close[1]<=price1 && Close[0]>price0) 
              {
                if(AllowSound) PlaySound("alert.wav"); 
                if(AllowAlertWindow) Alert(Symbol(),"--- UP");   
              //  Print(Symbol(),"--- UP");
                PrevAlertTime = TimeCurrent();     

                ObjectCreate("tpl",OBJ_LABEL,0,0,0);
                ObjectSet("tpl", OBJPROP_XDISTANCE,10);
                ObjectSet("tpl", OBJPROP_YDISTANCE,20); 
                ObjectSet("tpl", OBJPROP_CORNER,3);                        
                ObjectSetText("tpl","This Currency Breaks UP ",16,"Times New Roman",Red);
              }
            if (Close[1]>=price1 && Close[0]<price0) 
              { 
                if(AllowSound) PlaySound("alert.wav");
                if(AllowAlertWindow) Alert(Symbol(),"--- DOWN");
               // Print(Symbol(),"--- D"); 
                PrevAlertTime = TimeCurrent();
                
                ObjectCreate("tpl",OBJ_LABEL,0,0,0);
                ObjectSet("tpl", OBJPROP_XDISTANCE,10);
                ObjectSet("tpl", OBJPROP_YDISTANCE,20); 
                ObjectSet("tpl", OBJPROP_CORNER,2);                        
                ObjectSetText("tpl","This Currency Breaks DOWN ",16,"Times New Roman",Red);                
                
              }
            WindowRedraw();  
           }
         if (TimeCurrent()-Prevtext>KeepText_Minute*60)  
           {
              if(ObjectFind("tpl")==0) ObjectDelete("tpl");
              Prevtext = TimeCurrent();
           }
                  
           
       }
     }      

  return(0);
}



Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar


Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features:

It plays sound alerts
It issuies visual alerts to the screen