Индикатор PivotPoints

 
Индикатор показывает дневные опорные точки

H, L, C - High, Low, Close предыдущего дня

Рассчеты:
Вычисляется центр вращения так P = (H + L + C) / 3
Тогда Сопротивление 1 уровня R1 = 2P -L
Поддержка 1 уровня S1 = 2P - H
Второго уровня
R2 = P +(H - L)
S2 = P - (H - L)
И третьего
R3 = R1 + (H - L )
S3 = S1 - (H - L)

Исходный код:

//+------------------------------------------------------------------+
//|                                                  PivotPoints.mq4 |
//|                                     Copyright © 2004, SelfProfit |
//|                                        http://www.selfprofit.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, Äìèòðèé Àëüõèìîâè÷"
#property link      "http://www.selfprofit.com"

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Green
#property indicator_color2 Aqua
#property indicator_color3 Aqua
#property indicator_color4 Aqua
#property indicator_color5 Red
#property indicator_color6 Red
#property indicator_color7 Red

extern int          CountBars = 500; 
extern double       MinPrice = 1.0;
extern double       MaxPrice = 1.5;
extern double       ClosePrice = 2.0;


//---- buffers
double PivotCentre[];
double R1[];
double S1[];
double R2[];
double S2[];
double R3[];
double S3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,PivotCentre);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,R1);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,R2);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,R3);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,S1);
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,S2);
   SetIndexStyle(6,DRAW_LINE);
   SetIndexBuffer(6,S3);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  if(Period() != 60) 
   return;
   
  ObjectCreate("selfprofit_link", OBJ_LABEL, 0, 0,0);
  ObjectSet("selfprofit_link", OBJPROP_XDISTANCE,0);
  ObjectSet("selfprofit_link", OBJPROP_YDISTANCE, 10);  
  ObjectSetText("selfprofit_link", "www.selfprofit.com", 11, "Verdana", White );      
  
   int    counted_bars=IndicatorCounted();
   int i = 0;
      
   int hour = Hour();
   int day = DayOfWeek();
   
   int barsToCount = Bars - counted_bars;
      
   while(i <= barsToCount)
   {
      int numberOfHours = 24;      
   
      MinPrice = Low[Lowest(NULL,0,MODE_LOW,numberOfHours,i+hour)];
      MaxPrice = High[ Highest(NULL, 0, MODE_HIGH, numberOfHours, i+hour) ];
      ClosePrice = Close[hour+i];
      
      hour--;
      if(hour == -1) 
      {
         if(day == 5)
            hour = 22;        
         else
            hour = 23;        
            
         day--;
        if(day < 1)
            day = 5;
      }

      PivotCentre[i] = (MinPrice + MaxPrice + ClosePrice)/3;
                  
      R1[i] = 2*PivotCentre[i]-MinPrice;
      S1[i] = 2*PivotCentre[i]-MaxPrice;      
      R2[i] = PivotCentre[i]+(R1[i]-S1[i]);
      S2[i] = PivotCentre[i] - (R1[i]-S1[i]);
      R3[i] = MaxPrice + 2*(PivotCentre[i] - MinPrice);
      S3[i] = MinPrice - 2*(MaxPrice - PivotCentre[i]);
      
   i++;
  }
//----
   return(0);
  }
//+------------------------------------------------------------------+
Причина обращения: