Navigation:Home > Content >

AllPivots_v2_(2).mq4

Time: 2018-07-23 | Download file:AllPivots_v2_(2).mq4

//+------------------------------------------------------------------+
//|                                                 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 indicator_chart_window

extern int  CountDays=10;
extern bool Plot_pivots=true;
extern bool Plot_ohlc=true;
extern bool Plot_fibpivots=true;

   datetime time1;
   datetime time2;
   double open,close,high,low;
   double P,R1,R2,R3,S1,S2,S3,M0,M1,M2;
   int shift, num;
     
   void ObjDel()
   {
      for (;num<=CountDays;num++)
      {
      ObjectDelete("Pivot["+num+"]");
      ObjectDelete("R1["+num+"]");
      ObjectDelete("R2["+num+"]");
      ObjectDelete("R3["+num+"]");
      ObjectDelete("S1["+num+"]");
      ObjectDelete("S2["+num+"]");
      ObjectDelete("S3["+num+"]");
      
      ObjectDelete("Y_High["+num+"]");
      ObjectDelete("T_Open["+num+"]");
      ObjectDelete("Y_low["+num+"]");
      
      ObjectDelete("FibR3["+num+"]");
      ObjectDelete("FibR2["+num+"]");
      ObjectDelete("FibR1["+num+"]");
      ObjectDelete("FibS1["+num+"]");
      ObjectDelete("FibS2["+num+"]");
      ObjectDelete("FibS3["+num+"]");
      }
   }
   void PlotLine(string name,double value,double line_color,double style, int width)
   {
   ObjectCreate(name,OBJ_TREND,0,time1,value,time2,value);
   ObjectSet(name, OBJPROP_WIDTH, width);
   ObjectSet(name, OBJPROP_STYLE, style);
   ObjectSet(name, OBJPROP_RAY, false);
   ObjectSet(name, OBJPROP_BACK, true);
   ObjectSet(name, OBJPROP_COLOR, line_color);
    }        
int init()
  {

  return(0);
  }
   
   
int deinit()
  {
   ObjDel();
   Comment("");
   return(0);
  }

int start()
  {
  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=high;
  M1=iOpen(NULL,PERIOD_D1,shift);
  M2=low;
  
  double q,p,fibr3,fibr2,fibr1,fibs1,fibs2,fibs3;
  
   q = (high - low);
   p = (high + low + close) / 3;
   
   fibr3 = p + (q * 1.000);
   fibr2 = p + (q * 0.618);
   fibr1 = p + (q * 0.382);
   fibs1 = p - (q * 0.382);
   fibs2 = p - (q * 0.618);
   fibs3 = p - (q * 1.000);
       
  time2=time1+PERIOD_D1*60;

  num=shift;
       
  PlotLine("Pivot["+num+"]",P,RoyalBlue,0, 1);
  if(Plot_pivots)
  {
        
   PlotLine("R1["+num+"]",R1,Maroon,0, 1);
   PlotLine("R2["+num+"]",R2,Crimson,0, 1);
   PlotLine("R3["+num+"]",R3,Red,0, 1);
               
   PlotLine("S1["+num+"]",S1,DarkGreen,0, 1);
   PlotLine("S2["+num+"]",S2,Green,0, 1);
   PlotLine("S3["+num+"]",S3,Lime,0, 1);
  }
         
  if(Plot_ohlc)
  {
   PlotLine("Y_High["+num+"]",M0,White,3, 1);
   PlotLine("T_Open["+num+"]",M1,Yellow,3, 1);
   PlotLine("Y_Low["+num+"]",M2,White,3, 1);
  }
         
  if(Plot_fibpivots)
  {
   PlotLine("FibR3["+num+"]",fibr3,Red,2, 1);
   PlotLine("FibR2["+num+"]",fibr2,Crimson,2, 1);
   PlotLine("FibR1["+num+"]",fibr1,Maroon,2, 1);
      
   PlotLine("FibS1["+num+"]",fibs1,DarkGreen,2, 1);
   PlotLine("FibS2["+num+"]",fibs2,Green,2, 1);
   PlotLine("FibS3["+num+"]",fibs3,Lime,2, 1);
  }
  }
   return(0);
  }
//+------------------------------------------------------------------+

Recommend