Navigation´╝ÜHome > Content >

MondayH4Box.mq4

Time: 2017-07-03 | Download file:MondayH4Box.mq4

//+------------------------------------------------------------------+
//|                                                  MondayH4Box.mq4 |
//|                                    Modified from WeeklyPivot.mq4 |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Crimson
#property indicator_color2 RoyalBlue
#property indicator_color3 Crimson
#property indicator_color4 RoyalBlue
#property indicator_color5 Crimson
#property indicator_color6 RoyalBlue
#property indicator_color7 Crimson
#property indicator_color8 RoyalBlue
//---- input parameters

//---- buffers
double Lo1Buffer[];
double Hi1Buffer[];
double Lo2Buffer[];
double Hi2Buffer[];
double Lo3Buffer[];
double Hi3Buffer[];
double Lo4Buffer[];
double Hi4Buffer[];
double Lo1,Hi1,Lo2,Hi2,Lo3,Hi3,Lo4,Hi4;
double H4Low, H4High;

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;


//---- indicator line
   SetIndexStyle(0,DRAW_LINE,0,2);
   SetIndexStyle(1,DRAW_LINE,0,2);
   SetIndexStyle(2,DRAW_LINE,2,1);
   SetIndexStyle(3,DRAW_LINE,2,1);
   SetIndexStyle(4,DRAW_LINE,2,1);
   SetIndexStyle(5,DRAW_LINE,2,1);
   SetIndexStyle(6,DRAW_LINE,2,1);
   SetIndexStyle(7,DRAW_LINE,2,1);
   SetIndexBuffer(0,Lo1Buffer);
   SetIndexBuffer(1,Hi1Buffer);
   SetIndexBuffer(2,Lo2Buffer);
   SetIndexBuffer(3,Hi2Buffer);
   SetIndexBuffer(4,Lo3Buffer);
   SetIndexBuffer(5,Hi3Buffer);
   SetIndexBuffer(6,Lo4Buffer);
   SetIndexBuffer(7,Hi4Buffer);


//---- name for DataWindow and indicator subwindow label
   short_name="Weekly H4 Box";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);

//----
   SetIndexDrawBegin(0,1);
//----
 

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

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()

  {
   int counted_bars=IndicatorCounted();

   int limit, i;
//---- indicator calculation

   if(counted_bars<0) return(-1);

   limit=(Bars-counted_bars)-1;


   for (i=limit; i>=0;i--)
   { 

      // Monday
	   if ( 1 == TimeDayOfWeek(Time[i]) && 1 != TimeDayOfWeek(Time[i+1]) )
	   {
		   H4High = iHigh(0,PERIOD_H4,i);
		   H4Low  = iLow(0,PERIOD_H4,i);
      }

      Hi1 = H4High;
      Lo1 = H4Low;
      Hi2 = H4High + (H4High-H4Low);
      Lo2 = H4Low - (H4High-H4Low);
      Hi3 = H4High + 2*(H4High-H4Low);
      Lo3 = H4Low - 2*(H4High-H4Low); 
      Hi4 = H4High + 3*(H4High-H4Low);
      Lo4 = H4Low - 3*(H4High-H4Low); 
    
      Lo1Buffer[i]=Lo1;
      Hi1Buffer[i]=Hi1;
      Lo2Buffer[i]=Lo2;
      Hi2Buffer[i]=Hi2;
      Lo3Buffer[i]=Lo3;
      Hi3Buffer[i]=Hi3;
      Lo4Buffer[i]=Lo4;
      Hi4Buffer[i]=Hi4;

   }









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

Recommend