Navigation´╝ÜHome > Content >

Lines_HiLo__Periodical.mq4

Time: 2016-10-16 | Download file:Lines_HiLo__Periodical.mq4

//+------------------------------------------------------------------+
//|                                                        Lines_HiLo_Periodical.mq4 |
//|                      
//|                                      
//+------------------------------------------------------------------+
#property copyright "TradeForex"
#property link      ""

#property indicator_chart_window




//extern int Lookback_Period = 1
extern int Days_into_Curr_Week = 1;
extern int Days_into_Curr_Mnth = 1;
extern int Days_into_Curr_Year = 109;
extern int _Days_into_Curr_Year_To_May31_ = 109;
extern int No_of_Days_in_Prev_Wk = 5;
extern int Days_in_Prev_Month = 23;
extern int Days_in_Prev_Year = 245;







//int DayOfYear();
//double Curr_Yr_Daily_Bars_To_Today = 0;


double Daily_Period_Low=0;
double Daily_Period_High=0;
double Daily_Period_Low_Line;
double Daily_Period_High_Line;



double Curr_Wk_Period_High = 0;
double Curr_Wk_Period_Low = 0;
double Prev_Wk_Period_High = 0;
double Prev_Wk_Period_Low = 0;

double Curr_Wk_Period_High_Line;
double Curr_Wk_Period_Low_Line;

double Prev_Wk_Period_High_Line;
double Prev_Wk_Period_Low_Line;


double Curr_Month_Period_Low=0;
double Curr_Month_Period_High=0;
double Curr_Month_Period_Low_Line;
double Curr_Month_Period_High_Line;

double Prev_Month_Period_Low=0;
double Prev_Month_Period_High=0;
double Prev_Month_Period_Low_Line;
double Prev_Month_Period_High_Line;

double Curr_Year_Period_Low=0;
double Curr_Year_Period_High=0;
double Curr_Year_Period_Low_Line;
double Curr_Year_Period_High_Line;

double Prev_Year_Period_Low=0;
double Prev_Year_Period_High=0;
double Prev_Year_Period_Low_Line;
double Prev_Year_Period_High_Line;




//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

   
int init()
  {


   return(0);
  }

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
        return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{


        Daily_Period_High =High[Highest(NULL,0,MODE_HIGH,1,1)];
        Daily_Period_Low =Low[Lowest(NULL,0,MODE_LOW,1,1)];
        Daily_Period_Low_Line =  (Daily_Period_Low );
        Daily_Period_High_Line =  (Daily_Period_High );
        
        Curr_Wk_Period_High =High[Highest(NULL,0,MODE_HIGH,Days_into_Curr_Week,0 )];    
        Curr_Wk_Period_Low =Low[Lowest(NULL,0,MODE_LOW,Days_into_Curr_Week,0 )];
   
        Prev_Wk_Period_High =High[Highest(NULL,0,MODE_HIGH,No_of_Days_in_Prev_Wk,Days_into_Curr_Week)];
        Prev_Wk_Period_Low =Low[Lowest(NULL,0,MODE_LOW,No_of_Days_in_Prev_Wk,Days_into_Curr_Week)];
      
      
        Curr_Wk_Period_High_Line =  (Curr_Wk_Period_High );      
        Curr_Wk_Period_Low_Line =  (Curr_Wk_Period_Low );
      
        Prev_Wk_Period_High_Line =  (Prev_Wk_Period_High );
        Prev_Wk_Period_Low_Line =  (Prev_Wk_Period_Low );
         
        Curr_Month_Period_High =High[Highest(NULL,0,MODE_HIGH,Days_into_Curr_Mnth,0)];
        Curr_Month_Period_Low =Low[Lowest(NULL,0,MODE_LOW,Days_into_Curr_Mnth,0)];
        Curr_Month_Period_Low_Line =  (Curr_Month_Period_Low );
        Curr_Month_Period_High_Line =  (Curr_Month_Period_High ); 
        
        Prev_Month_Period_High =High[Highest(NULL,0,MODE_HIGH,Days_in_Prev_Month,Days_into_Curr_Mnth)];
        Prev_Month_Period_Low =Low[Lowest(NULL,0,MODE_LOW,Days_in_Prev_Month,Days_into_Curr_Mnth)];
        Prev_Month_Period_Low_Line =  (Prev_Month_Period_Low );
        Prev_Month_Period_High_Line =  (Prev_Month_Period_High );
        
        Curr_Year_Period_High =High[Highest(NULL,0,MODE_HIGH,Days_into_Curr_Year,0)];
        Curr_Year_Period_Low =Low[Lowest(NULL,0,MODE_LOW,Days_into_Curr_Year,0)];
        Curr_Year_Period_Low_Line =  (Curr_Year_Period_Low );
        Curr_Year_Period_High_Line =  (Curr_Year_Period_High );    
        
        Prev_Year_Period_High =High[Highest(NULL,0,MODE_HIGH,Days_in_Prev_Year,Days_into_Curr_Year)];
        Prev_Year_Period_Low =Low[Lowest(NULL,0,MODE_LOW,Days_in_Prev_Year,Days_into_Curr_Year)];
       
        Prev_Year_Period_Low_Line =  (Prev_Year_Period_Low );
        Prev_Year_Period_High_Line =  (Prev_Year_Period_High );          

   {
      
      
      SetLevel("Current Week High", Curr_Wk_Period_High_Line, Salmon); //Green
      SetLevel("Current Week Low", Curr_Wk_Period_Low_Line , Salmon); //G      
      SetLevel("Previous Week High", Prev_Wk_Period_High_Line, LightSalmon); //Green
      SetLevel("Previous Week Low", Prev_Wk_Period_Low_Line, LightSalmon); //G
      
      SetLevel("Current Months High", Curr_Month_Period_High_Line, Green); //Green
      SetLevel("Current Months Low", Curr_Month_Period_Low_Line, Green); //G
      
      SetLevel("Previous Months High", Prev_Month_Period_High_Line, LightGreen); //Green
      SetLevel("Previous Months Low", Prev_Month_Period_Low_Line, LightGreen); //G
      
      SetLevel("Current Year High", Curr_Year_Period_High_Line, Gold); //Green
      SetLevel("Current Year Low", Curr_Year_Period_Low_Line, Gold); //G
      SetLevel("Previous Year High", Prev_Year_Period_High_Line, Beige); //Green
      SetLevel("Previous Year Low", Prev_Year_Period_Low_Line, Beige); //G
      
      SetLevel("Yesterdays High", Daily_Period_High_Line, Blue); //Blue
      SetLevel("Yesterdays Low", Daily_Period_Low_Line, Blue); //Blue
      
       }
   

  
   return(0);
}

void SetLevel(string text, double level, color col1)
{
   string labelname= text + " Label";
   string linename= text + " Line";

   if (ObjectFind(labelname) != 0) {
      ObjectCreate(labelname, OBJ_TEXT, 0, Time[20], level);
      ObjectSetText(labelname, " " + text, 8, "Arial", White);
   }
   else {
      ObjectMove(labelname, 0, Time[20], level);
   }
   
   if (ObjectFind(linename) != 0) {
      ObjectCreate(linename, OBJ_HLINE, 0, Time[40], level);
      ObjectSet(linename, OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet(linename,OBJPROP_LEVELWIDTH, 5);
      ObjectSet(linename, OBJPROP_COLOR, col1);
      
      }
   else {
      ObjectMove(linename, 0, Time[40], level);
      
   }
}
      

Recommend