MonthlyPivot_001





//+------------------------------------------------------------------+
//|                                                    Monthly 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 Orchid
#property indicator_color2 SlateBlue
#property indicator_color3 IndianRed
#property indicator_color4 SlateBlue
#property indicator_color5 IndianRed
#property indicator_color6 DarkOliveGreen
#property indicator_color7 DarkOliveGreen
//---- buffers
double PBuffer[];
double S1Buffer[];
double R1Buffer[];
double S2Buffer[];
double R2Buffer[];
double S3Buffer[];
double R3Buffer[];

double P,S1,R1,S2,R2,S3,R3,last_month_high,last_month_low,last_month_close,this_month_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,1);
   SetIndexStyle(1,DRAW_LINE,0,1);
   SetIndexStyle(2,DRAW_LINE,0,1);
   SetIndexStyle(3,DRAW_LINE,0,1);
   SetIndexStyle(4,DRAW_LINE,0,1);
   SetIndexStyle(5,DRAW_LINE,0,1);
   SetIndexStyle(6,DRAW_LINE,0,1);
   SetIndexLabel(0,"Monthly Pivot Point");
   SetIndexLabel(1,"Monthly Support 1");
   SetIndexLabel(2,"Monthly Resistant 1");
   SetIndexLabel(3,"Monthly Support 2");
   SetIndexLabel(4,"Monthly Resistant 2");
   SetIndexLabel(5,"Monthly Support 3");
   SetIndexLabel(6,"Monthly Resistant 3");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("Monthly Pivot");
   ObjectDelete("Monthly Sup1");
   ObjectDelete("Monthly Res1");
   ObjectDelete("Monthly Sup2");
   ObjectDelete("Monthly Res2");
   ObjectDelete("Monthly Sup3");
   ObjectDelete("Monthly Res3");   
   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_D1) return(-1);
   if(counted_bars==0)
     {
      ObjectCreate("Monthly Pivot",OBJ_TEXT,0,0,0);
      ObjectSetText("Monthly Pivot","                            Monthly Pivot Point",10,"Arial",OrangeRed);
      ObjectCreate("Monthly Sup1",OBJ_TEXT,0,0,0);
      ObjectSetText("Monthly Sup1","        mS 1",10,"Arial",OrangeRed);
      ObjectCreate("Monthly Res1",OBJ_TEXT,0,0,0);
      ObjectSetText("Monthly Res1","        mR 1",10,"Arial",OrangeRed);
      ObjectCreate("Monthly Sup2",OBJ_TEXT,0,0,0);
      ObjectSetText("Monthly Sup2","        mS 2",10,"Arial",OrangeRed);
      ObjectCreate("Monthly Res2",OBJ_TEXT,0,0,0);
      ObjectSetText("Monthly Res2","        mR 2",10,"Arial",OrangeRed);
      ObjectCreate("Monthly Sup3",OBJ_TEXT,0,0,0);
      ObjectSetText("Monthly Sup3","        mS 3",10,"Arial",OrangeRed);
      ObjectCreate("Monthly Res3",OBJ_TEXT,0,0,0);
      ObjectSetText("Monthly Res3","        mR 3",10,"Arial",OrangeRed);
     }
   for(i=limit-1; i>=0; i--)
      {
       // 1sts Days of Month
	    if(TimeDay(Time[i])<=3 && TimeDay(Time[i+1])>=26)
	      {
		    last_month_close=Close[i+1];
		    this_month_open=Open[i];		
		    P=(last_month_high+last_month_low+last_month_close+this_month_open)/4;
          R1=(2*P)-last_month_low;
          S1=(2*P)-last_month_high;
          R2=P+(last_month_high-last_month_low);
          S2=P-(last_month_high-last_month_low);
          R3=(2*P)+(last_month_high-(2*last_month_low));
          S3=(2*P)-((2*last_month_high)-last_month_low); 
        	 ObjectMove("Monthly Pivot",0,Time[i],P);
          ObjectMove("Monthly Sup1",0,Time[i],S1);
          ObjectMove("Monthly Res1",0,Time[i],R1);
          ObjectMove("Monthly Sup2",0,Time[i],S2);
          ObjectMove("Monthly Res2",0,Time[i],R2);
          ObjectMove("Monthly Sup3",0,Time[i],S3);
          ObjectMove("Monthly Res3",0,Time[i],R3);
          last_month_low=Low[i];
          last_month_high=High[i];
         }       
       last_month_low=MathMin(last_month_low,Low[i]);   
       last_month_high=MathMax(last_month_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: