YearlyPivot-mids





//+------------------------------------------------------------------+
//|                                                     Yearly Pivot |
//|                                    Copyright © 2006, Profitrader |
//|                                    Coded/Verified by Profitrader |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Profitrader."
#property link      "profitrader@inbox.ru"

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Black
#property indicator_color2 White
#property indicator_color3 White
#property indicator_color4 White
#property indicator_color5 White
#property indicator_color6 White
#property indicator_color7 White
//---- buffers
double PBuffer[];
double S1Buffer[];
double R1Buffer[];
double S2Buffer[];
double R2Buffer[];
double S3Buffer[];
double R3Buffer[];

double P,S1,R1,S2,R2,S3,R3,last_year_high,last_year_low,last_year_close,this_year_open;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexBuffer(0,PBuffer);
   SetIndexBuffer(1,S1Buffer);
   SetIndexBuffer(2,R1Buffer);
   SetIndexBuffer(3,S2Buffer);
   SetIndexBuffer(4,R2Buffer);
   SetIndexBuffer(5,S3Buffer);
   SetIndexBuffer(6,R3Buffer);
   SetIndexStyle(0,DRAW_LINE,0,2);
   SetIndexStyle(1,DRAW_LINE,4,1);
   SetIndexStyle(2,DRAW_LINE,4,1);
   SetIndexStyle(3,DRAW_LINE,4,1);
   SetIndexStyle(4,DRAW_LINE,4,1);
   SetIndexStyle(5,DRAW_LINE,4,1);
   SetIndexStyle(6,DRAW_LINE,4,1);
   SetIndexLabel(0,"Yearly Pivot Point");
   SetIndexLabel(1,"Yearly Mid Support 1 ");
   SetIndexLabel(2,"Yearly Mid Resistant 1 ");
   SetIndexLabel(3,"Yearly Mid Support 2");
   SetIndexLabel(4,"Yearly Mid Resistant 2");
   SetIndexLabel(5,"Yearly Mid Support 3");
   SetIndexLabel(6,"Yearly Mid Resistant 3");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("Yearly Pivot");
   ObjectDelete("Yearly MSup1");
   ObjectDelete("Yearly MRes1");
   ObjectDelete("Yearly MSup2");
   ObjectDelete("Yearly MRes2");
   ObjectDelete("Yearly MSup3");
   ObjectDelete("Yearly MRes3");   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;  
   int limit=Bars-counted_bars;
   
   if(Period()>PERIOD_W1) return(-1);
   if(counted_bars==0)
     {
      ObjectCreate("Yearly Pivot",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly Pivot","                            Yearly Pivot Point",8,"Arial",Black);
      ObjectCreate("Yearly MSup1",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly MSup1","        yS 1",8,"Arial",White);
      ObjectCreate("Yearly MRes1",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly MRes1","        yMR 1",8,"Arial",White);
      ObjectCreate("Yearly MSup2",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly MSup2","        yMS 2",8,"Arial",White);
      ObjectCreate("Yearly MRes2",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly MRes2","        yMR 2",8,"Arial",White);
      ObjectCreate("Yearly MSup3",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly MSup3","        yMS 3",8,"Arial",White);
      ObjectCreate("Yearly MRes3",OBJ_TEXT,0,0,0);
      ObjectSetText("Yearly MRes3","        yMR 3",8,"Arial",White);
     }
   for(i=limit-1; i>=0; i--)
      {
       // 1sts Days of Year
	    if(TimeDayOfYear(Time[i])<=10 && TimeDayOfYear(Time[i+1])>=355)
	      {
		    last_year_close=Close[i+1];
		    this_year_open=Open[i];		
		    P=(last_year_high+last_year_low+last_year_close+this_year_open)/4;
          R1=(((2*P)-last_year_low)-P)/2 +P;
          S1=(((2*P)-last_year_high)-P)/2 +P;
          R2=((P+(last_year_high-last_year_low))-((2*P)-last_year_low))/2 + (2*P)-last_year_low;
          S2=(((2*P)-last_year_high)-(P-(last_year_high-last_year_low)))/2 + P-(last_year_high-last_year_low);
          R3=((2*P)+(last_year_high-(2*last_year_low)) - (P+(last_year_high-last_year_low)))/2 + P+(last_year_high-last_year_low);
          S3=((P-(last_year_high-last_year_low))-((2*P)-((2*last_year_high)-last_year_low)))/2 + (2*P)-((2*last_year_high)-last_year_low);  
        	 ObjectMove("Yearly Pivot",0,Time[i],P);
          ObjectMove("Yearly MSup1",0,Time[i],S1);
          ObjectMove("Yearly MRes1",0,Time[i],R1);
          ObjectMove("Yearly MSup2",0,Time[i],S2);
          ObjectMove("Yearly MRes2",0,Time[i],R2);
          ObjectMove("Yearly MSup3",0,Time[i],S3);
          ObjectMove("Yearly MRes3",0,Time[i],R3);
          last_year_low=Low[i];
          last_year_high=High[i];
         }       
       last_year_low=MathMin(last_year_low,Low[i]);   
       last_year_high=MathMax(last_year_high,High[i]);
       PBuffer[i]=P;
       S1Buffer[i]=S1;
       R1Buffer[i]=R1;
       S2Buffer[i]=S2;
       R2Buffer[i]=R2;
       S3Buffer[i]=S3;
       R3Buffer[i]=R3;
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+



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_LINE

Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: