Pivot_DOTS





//+------------------------------------------------------------------+
//|                                                   Pivot_DOTS.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//|                                                 AllPivots_v1.mq4 |
//|                                  Copyright © 2006, Forex-TSD.com |
//|                         Written by IgorAD,igorad2003@yahoo.co.uk |   
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |                                      
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Forex-TSD.com "
#property link      "http://www.forex-tsd.com/"
#property link      "Modified by cja"

#property indicator_chart_window

extern int GMTshift=0;
extern bool Plot_PIVOTS=true;
extern bool Plot_M_Levels=true;
extern int DOT_Type = 174;
extern color Central_PIVOT = Lime;
extern int PIVOT_Size = 2;
extern color R1_R2_R3 = Blue;
extern color S1_S2_S3 = Red;
extern int S_R_Levels_Size = 1; 
extern color M0_M1_M2 = Red;
extern color M3_M4_M5 = Blue; 
extern int MLevelS_Size = 0;
extern bool Show_StartTime = true; 
extern color REC_color = Blue;
#define DailyHILO "DailyHILO"

double day_high;
double day_low;
double yesterday_open;
double today_open;
double cur_day;
double prev_day;

double yesterday_high=0;
double yesterday_low=0;
double yesterday_close=0;

   datetime time1;
   datetime time2;
   double open,close,high,low;
   double P,R1,R2,R3,S1,S2,S3,M0,M1,M2,M3,M4,M5;
   double H1,H2,H3,H4,L1,L2,L3,L4,Range;
   int shift, num;
     
   void ObjDel()
   {
      for (;num<=0;num++)
      {
      ObjectDelete("PP["+num+"]");
      ObjectDelete("R1["+num+"]");
      ObjectDelete("R2["+num+"]");
      ObjectDelete("R3["+num+"]");
      ObjectDelete("S1["+num+"]");
      ObjectDelete("S2["+num+"]");
      ObjectDelete("S3["+num+"]");
      
      ObjectDelete("M0["+num+"]");
      ObjectDelete("M1["+num+"]");
      ObjectDelete("M2["+num+"]");
      ObjectDelete("M3["+num+"]");
      ObjectDelete("M4["+num+"]");
      ObjectDelete("M5["+num+"]");
      
      }
      
      //---- Get new daily prices & calculate pivots
   day_high=0;
   day_low=0;
   yesterday_open=0;
   today_open=0;
   cur_day=0;
   prev_day=0;
   
   int cnt=720;

   while (cnt!= 0)
   {
	  if (TimeDayOfWeek(Time[cnt]) == 0)
	  {
        cur_day = prev_day;
	  }
	  else
	  {
        cur_day = TimeDay(Time[cnt]- (GMTshift*3600));
	  }
	
  	  if (prev_day != cur_day)
	  {
		 yesterday_close = Close[cnt+1];
		 today_open = Open[cnt];
		 yesterday_high = day_high;
		 yesterday_low = day_low;

		 day_high = High[cnt];
		 day_low  = Low[cnt];

		 prev_day = cur_day;
	  }
   
     if (High[cnt]>day_high)
     {
       day_high = High[cnt];
     }
   
     if (Low[cnt]<day_low)
     {
       day_low = Low[cnt];
     }
	
	  cnt--;

  }
   }

   void PlotLine(string name,double value,double line_color,double style)
   {
   ObjectCreate(name,OBJ_ARROW,0,Time[0],value,Time[0],value);
   ObjectSet(name, OBJPROP_ARROWCODE,DOT_Type);
   ObjectSet(name, OBJPROP_WIDTH, S_R_Levels_Size);
   ObjectSet(name, OBJPROP_STYLE, style);
   ObjectSet(name, OBJPROP_COLOR, line_color);
    }        
    
     void PlotLinemm(string namemm,double value,double line_color,double style)
   {
   ObjectCreate(namemm,OBJ_ARROW,0,Time[0],value,Time[0],value);
   ObjectSet(namemm, OBJPROP_ARROWCODE,DOT_Type);
   ObjectSet(namemm, OBJPROP_WIDTH, MLevelS_Size);
   ObjectSet(namemm, OBJPROP_STYLE, style);
   ObjectSet(namemm, OBJPROP_COLOR, line_color);
    }
    
     void PlotLinep(string namep,double value,double line_color,double style)
   {
   ObjectCreate(namep,OBJ_ARROW,0,Time[0],value,Time[0],value);
   ObjectSet(namep, OBJPROP_ARROWCODE,DOT_Type);
   ObjectSet(namep, OBJPROP_WIDTH, PIVOT_Size);
   ObjectSet(namep, OBJPROP_STYLE, style);
   ObjectSet(namep, OBJPROP_COLOR, line_color);
    }
    
      
int init()
  {

  return(0);
  }
   
   
int deinit()
  {
  ObjectsDeleteAll(0,OBJ_VLINE);
  ObjectsDeleteAll(0,OBJ_ARROW);
   ObjDel();
   Comment("");
   return(0);
  }

int start()
  {
  
  CreateHL();
}

void CreateObj(string objName, double start, double end, color clr)
  {
   ObjectCreate(objName, OBJ_VLINE, 0, iTime(NULL,1440,0)+GMTshift*3600, start, Time[0], end);
   ObjectSet(objName, OBJPROP_COLOR, clr);

  }
   void DeleteCreateObj()
   {
   ObjectDelete(DailyHILO);
   }
   void CreateHL()
   {
   DeleteCreateObj();
   
   ObjectsDeleteAll(0,OBJ_VLINE);
   
   double DHI = iHigh(NULL,PERIOD_D1,0);
   double DLO = iLow(NULL,PERIOD_D1,0);
     
    if (Show_StartTime==true)
    {  
   CreateObj(DailyHILO,0,0, REC_color);
    }    
  int i;
     
  ObjDel();
  num=0;
  
  //for (shift=CountDays-1;shift>=0;shift--)
  {
  time1=iTime(NULL,PERIOD_D1,shift);
  i=shift-1;
  if (i<0) 
  time2=Time[0];
  else
  time2=iTime(NULL,PERIOD_D1,i)-Period()*60;
         
 /* high  = iHigh(NULL,PERIOD_D1,shift+1);
  low   = iLow(NULL,PERIOD_D1,shift+1);
  open  = iOpen(NULL,PERIOD_D1,shift+1);
  close = iClose(NULL,PERIOD_D1,shift+1);
       
  P  = (high+low+close)/3.0;
        
  R1 = 2*P-low;
  R2 = P+(high - low);
  R3 = (2*P)+(high-(2*low));
        
  S1 = 2*P-high;
  S2 = P-(high - low);
  S3 = (2*P)-((2*high)-low);
         
  M0=0.5*(S2+S3);
  M1=0.5*(S1+S2);
  M2=0.5*(P+S1);
  M3=0.5*(P+R1);
  M4=0.5*(R1+R2);
  M5=0.5*(R2+R3);*/
  
   double P = (yesterday_high + yesterday_low + yesterday_close)/3;//Pivot
  

    //Pivots & M Pivots
    double R3 = ( 2 * P ) + ( yesterday_high - ( 2 * yesterday_low ));
    double R2 = P + ( yesterday_high - yesterday_low );
    double R1 = ( 2 * P ) - yesterday_low;
    double S1 = ( 2 * P ) - yesterday_high;
    double S2 = P - ( yesterday_high- yesterday_low);
    double S3 = ( 2 * P ) - ( ( 2 * yesterday_high ) - yesterday_low );
         
    double M0 = (S2 + S3)/2;
    double M1 = (S1 + S2)/2;
    double M2 = (P + S1)/2;
    double M3 = (P + R1)/2; 
    double M4 = (R1 + R2)/2;
    double M5 = (R2 + R3)/2; 
         
        
  time2=time1+PERIOD_D1*8;
 
  num=shift;
       
  PlotLinep("PP["+num+"]",P,Central_PIVOT,0);
  if(Plot_PIVOTS)
  {
        
   PlotLine("R1["+num+"]",R1,R1_R2_R3,0);
   PlotLine("R2["+num+"]",R2,R1_R2_R3,0);
   PlotLine("R3["+num+"]",R3,R1_R2_R3,0);
               
   PlotLine("S1["+num+"]",S1,S1_S2_S3,0);
   PlotLine("S2["+num+"]",S2,S1_S2_S3,0);
   PlotLine("S3["+num+"]",S3,S1_S2_S3,0);
  }
         
  if(Plot_M_Levels)
  {
   PlotLinemm("M0["+num+"]",M0,M0_M1_M2,0);
   PlotLinemm("M1["+num+"]",M1,M0_M1_M2,0);
   PlotLinemm("M2["+num+"]",M2,M0_M1_M2,0);
   PlotLinemm("M3["+num+"]",M3,M3_M4_M5,0);
   PlotLinemm("M4["+num+"]",M4,M3_M4_M5,0);
   PlotLinemm("M5["+num+"]",M5,M3_M4_M5,0);
  }
 
  }
   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 highest prices of each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: