Floor_Pivots_Weekly_Mid





//+------------------------------------------------------------------+
//|                                       Pivot_Range_Weekly_Mid.mq4 |
//|                         Copyright © 2009, kris.pivo[at]gmail.com |
//+------------------------------------------------------------------+
#property copyright "© Kris, 2009"                                 //|
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 C'000,100,000'
#property indicator_color2 C'000,100,000'
#property indicator_color3 C'080,080,080'
#property indicator_color4 C'200,200,200'
#property indicator_color5 C'080,080,080'
#property indicator_color6 C'100,000,000'
#property indicator_color7 C'100,000,000'

//---- input parameters
int fontsize=8;
//---- buffers
double BufferR2R1[]; // M4 - Mid R1-R2
double BufferR1PP[]; // M3 - Mid PP-R1
double BufferPRH[];  // Pivot Range High
//double BufferPP[];   // Pivot Point
double BufferPRL[];  // Pivot Range Low
double BufferPPS1[]; // M2 - Mid PP-S1
double BufferS1S2[]; // M1 - Mid S1-S2

double WH,WL,WC,PP,PD,PRH,PRL;
double S1,R1,S2,R2,S3,R3;
double R2R1, R1PP, PPS1, S1S2;
double last_week_high, last_week_low, last_week_close, this_week_open;
//+------------------------------------------------------------------+

int deinit() {
   ObjectDelete("PivR2R1");
   ObjectDelete("PivR1PP");
   ObjectDelete("PivPRH");
//   ObjectDelete("PivPP");
   ObjectDelete("PivPRL");
   ObjectDelete("PivPPS1");
   ObjectDelete("PivS1S2");
   
	ObjectDelete("LabPivR2R1");
	ObjectDelete("LabPivR1PP");
	ObjectDelete("LabPivPRH");
//	ObjectDelete("LabPivPP");
	ObjectDelete("LabPivPRL");
	ObjectDelete("LabPivPPS1");
	ObjectDelete("LabPivS1S2");
	
	Comment("");
	return(0); }
//+------------------------------------------------------------------+

int init()
  {
   string short_name;

   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,160);
   SetIndexBuffer(0,BufferR2R1);
   
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,160);
   SetIndexBuffer(1,BufferR1PP);
   
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,160);
   SetIndexBuffer(2,BufferPRH);
      
//   SetIndexStyle(3,DRAW_ARROW);
//   SetIndexArrow(3,167);
//   SetIndexBuffer(3,BufferPP);
   
   SetIndexStyle(4,DRAW_ARROW);
   SetIndexArrow(4,160);
   SetIndexBuffer(4,BufferPRL);
   
   SetIndexStyle(5,DRAW_ARROW);
   SetIndexArrow(5,160);
   SetIndexBuffer(5,BufferPPS1);
   
   SetIndexStyle(6,DRAW_ARROW);
   SetIndexArrow(6,160);
   SetIndexBuffer(6,BufferS1S2);
   
   short_name="Floor Pivot Mid Weekly";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
   SetIndexDrawBegin(0,1);
   return(0);  }

int start()
  {
   int counted_bars=IndicatorCounted();
   int limit, i;
   if (counted_bars==0)
     {
      ObjectCreate("PivR2R1", OBJ_TEXT, 0,0,0);
      ObjectSetText("PivR2R1", "                                     Weekly M4",fontsize,"Arial",indicator_color1);
      ObjectCreate("PivR1PP", OBJ_TEXT, 0,0,0);
      ObjectSetText("PivR1PP", "                                     Weekly M3",fontsize,"Arial",indicator_color2);
      ObjectCreate("PivPRH", OBJ_TEXT, 0,0,0);
      ObjectSetText("PivPRH", "                                      Weekly PR High",fontsize,"Arial",indicator_color3);
//      ObjectCreate("PivPP", OBJ_TEXT, 0,0,0);
//      ObjectSetText("PivPP", "                                       Weekly Pivot Point",fontsize,"Arial",indicator_color4);
      ObjectCreate("PivPRL", OBJ_TEXT, 0,0,0);
      ObjectSetText("PivPRL", "                                      Weekly PR Low",fontsize,"Arial",indicator_color5);
      ObjectCreate("PivPPS1", OBJ_TEXT, 0,0,0);
      ObjectSetText("PivPPS1", "                                     Weekly M2",fontsize,"Arial",indicator_color6);
      ObjectCreate("PivS1S2", OBJ_TEXT, 0,0,0);
      ObjectSetText("PivS1S2", "                                     Weekly M1",fontsize,"Arial",indicator_color7);
     }
   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]) )  // 0=Sunday, 1=Monday, ...
        {
         last_week_close=Close[i+1];
         this_week_open=Open[i];
         
         WH = last_week_high;
         WL = last_week_low;
         WC = last_week_close;
         
         PP = (WH + WL + WC)/3;
         PD = MathAbs(((WH + WL)/2) - PP);
         PRH = PP + PD;
         PRL = PP - PD;
         
			R1 = (2*PP)- WL;
			S1 = (2*PP)- WH;
			R2 = PP+(R1-S1);
			S2 = PP-(R1-S1);
			
			R2R1 = (R2+R1)/2;
			R1PP = (R1+PP)/2;
			PPS1 = (PP+S1)/2;
			S1S2 = (S1+S2)/2;
			
         last_week_low  = Low[i];
         last_week_high = High[i];
//----
         ObjectMove("PivR2R1", 0, Time[i],R2R1);
         ObjectMove("PivR1PP", 0, Time[i],R1PP);
         ObjectMove("PivPRH",  0, Time[i],PRH);
//         ObjectMove("PivPP",   0, Time[i],PP);
         ObjectMove("PivPRL",  0, Time[i],PRL);
         ObjectMove("PivPPS1", 0, Time[i],PPS1);
         ObjectMove("PivS1S2", 0, Time[i],S1S2);
        }
      last_week_high=MathMax(last_week_high, High[i]);
      last_week_low=MathMin(last_week_low, Low[i]);
      
      BufferR2R1[i] = R2R1;
      BufferR1PP[i] = R1PP;
      BufferPRH[i]  = PRH;
//      BufferPP[i]   = PP;
      BufferPRL[i]  = PRL;
      BufferPPS1[i] = PPS1;
      BufferS1S2[i] = S1S2;

   DoLabel( "LabPivR2R1", BufferR2R1[0], indicator_color1 );
   DoLabel( "LabPivR1PP", BufferR1PP[0], indicator_color2 );
   DoLabel( "LabPivPRH",  BufferPRH[0],  indicator_color3 );
//   DoLabel( "LabPivPP",   BufferPP[0],   indicator_color4 );
   DoLabel( "LabPivPRL",  BufferPRL[0],  indicator_color5 );
   DoLabel( "LabPivPPS1", BufferPPS1[0], indicator_color6 );
   DoLabel( "LabPivS1S2", BufferS1S2[0], indicator_color7 );
	}
	return(0); }
	
void DoLabel( string dName, double dValue, color dColor )
   {
   if (ObjectFind(dName) != 0)
      {
      ObjectCreate(dName,OBJ_ARROW,0,Time[0],dValue);
      ObjectSet(dName,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
      ObjectSet(dName,OBJPROP_COLOR,dColor);  
      } 
   else
      {
      ObjectMove(dName,0,Time[0],dValue);
      }
   }      
//+-----------------------------------------------------------------------------------------+
//|                                         THE END                                         |
//+-----------------------------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar
Series array that contains close prices for each bar
Series array that contains open prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains the highest prices of each bar


Indicator Curves created:

Implements a curve of type DRAW_ARROW


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: