//+------------------------------------------------------------------+
//|                                                CandleHighLow.mq4 |
//|                                                            GumRai
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "GumRai"
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
//--- input parameters
extern bool      DailyHighLow=true;
extern bool      WeeklyHighLow=true;
extern bool      MonthlyHighLow=true;
extern color     Colour_High=DodgerBlue;
extern color     Colour_Low=Red;
extern int       HistoryBars =3;

string MonthArray[13];
string storeobname[2000];
int storecount =0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators

MonthArray [1]="Jan";
MonthArray [2]="Feb";
MonthArray [3]="Mar";
MonthArray [4]="Apr";
MonthArray [5]="May";
MonthArray [6]="June";
MonthArray [7]="July";
MonthArray [8]="Aug";
MonthArray [9]="Sept";
MonthArray [10]="Oct";
MonthArray [11]="Nov";
MonthArray [12]="Dec";

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
   for( int i=storecount-1;i>=0;i--)
   {
  
   if(ObjectFind( storeobname[i]) !=-1)
   ObjectDelete(storeobname[i] ) ;
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
//----
   int i;
   
 if(DailyHighLow==true)
 {  
   for(i=1;i<=HistoryBars;i++)
   {
   double Dayhigh =iHigh(NULL,PERIOD_D1,i);
   double Daylow =iLow(NULL,PERIOD_D1,i);   
   datetime Daytime=iTime(NULL,PERIOD_D1,i);
   int  date=TimeDay(Daytime);
   string month=MonthArray[TimeMonth(Daytime)];
   //string writtenmonth= getmonth(month);
   string linename ="Daily High "+ date+" "+month;
     if(ObjectFind(linename) ==-1)
      {
      ObjectCreate(linename,OBJ_HLINE,0,Daytime,Dayhigh);
      ObjectSet( linename,OBJPROP_COLOR,Colour_High); 
      ObjectSet( linename,OBJPROP_BACK,true); 
      ObjectSet( linename,OBJPROP_STYLE,STYLE_DOT);
      
      
      storeobname[storecount]=linename;
      storecount++;
       
      }  
   linename ="Daily Low "+ date+" "+month;
      if(ObjectFind(linename) ==-1)
      {
      ObjectCreate(linename,OBJ_HLINE,0,Daytime,Daylow);
      ObjectSet( linename,OBJPROP_COLOR,Colour_Low); 
      ObjectSet( linename,OBJPROP_BACK,true); 
      ObjectSet( linename,OBJPROP_STYLE,STYLE_DOT);
      
      storeobname[storecount]=linename;
      storecount++;
      
      }   
   }
 } 
   
 if(MonthlyHighLow==true)
 {
   for(i=1;i<=HistoryBars;i++)
   {
   double Monhigh =iHigh(NULL,PERIOD_MN1,i);
   double Monlow =iLow(NULL,PERIOD_MN1,i);   
   datetime Montime=iTime(NULL,PERIOD_MN1,i);
  
   month=MonthArray[TimeMonth(Montime)];
   
   linename ="Monthly High "+ month;
     if(ObjectFind(linename) ==-1)
      {
      ObjectCreate(linename,OBJ_HLINE,0,Montime,Monhigh);
      ObjectSet( linename,OBJPROP_COLOR,Colour_High); 
      ObjectSet( linename,OBJPROP_BACK,true);
      storeobname[storecount]=linename;
      storecount++;
      }  
   linename ="Monthly Low "+month;
     if(ObjectFind(linename) ==-1)
     {
      ObjectCreate(linename,OBJ_HLINE,0,Montime,Monlow);
      ObjectSet( linename,OBJPROP_COLOR,Colour_Low); 
      ObjectSet( linename,OBJPROP_BACK,true);
      storeobname[storecount]=linename;
      storecount++;
     }  
   
   }   
}  

if(WeeklyHighLow==true)
 {
   for(i=1;i<=HistoryBars;i++)
   {
   double Weekhigh =iHigh(NULL,PERIOD_W1,i);
   double Weeklow =iLow(NULL,PERIOD_W1,i);   
   datetime Weektime=iTime(NULL,PERIOD_W1,i);
   date=TimeDay(Weektime);
   month=MonthArray[TimeMonth(Weektime)];
   
   linename ="Weekly High "+date+ month;
     if(ObjectFind(linename) ==-1)
      {
      ObjectCreate(linename,OBJ_HLINE,0,Weektime,Weekhigh);
      ObjectSet( linename,OBJPROP_COLOR,Colour_High); 
      ObjectSet( linename,OBJPROP_BACK,true);
      ObjectSet( linename,OBJPROP_STYLE,STYLE_DASHDOT);
      storeobname[storecount]=linename;
      storecount++;
      }  
   linename ="Weekly Low "+date+" "+month;
     if(ObjectFind(linename) ==-1)
     {
      ObjectCreate(linename,OBJ_HLINE,0,Weektime,Weeklow);
      ObjectSet( linename,OBJPROP_COLOR,Colour_Low); 
      ObjectSet( linename,OBJPROP_BACK,true);
      ObjectSet( linename,OBJPROP_STYLE,STYLE_DASHDOT);
      storeobname[storecount]=linename;
      storecount++;
     }  
   
   }   
}  
   
 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+


