Help With Pivot Point Moving Average Indicator

 
Hello, I am trying to write an indicator (my first). I need to the indicator to draw the average of the last 4 pivot point values. It also needs to draw the last bar's pivot point. The idea is that when the pivot point of last bar crosses above the average of 4 last bar's pivot points then it is a buy. Anyway, got this out of a book and i can't find the indicator anywhere. Thank you in advance for helping!
//+------------------------------------------------------------------+
//|                                                    PivotPtMA.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Yellow

double pivot1[];
double curAvg[];



int init()
  {
  
         SetIndexBuffer(0, pivot1);
         SetIndexStyle(0,DRAW_LINE, STYLE_SOLID, 1);
         SetIndexDrawBegin(0,4);
         
         
         SetIndexBuffer(1, curAvg);
         SetIndexStyle(1,DRAW_LINE, STYLE_SOLID, 1);
         SetIndexDrawBegin(1,4);
         
       

  }





int start()
  {
         
         int counted = IndicatorCounted();
         
         if(counted < 0) return (-1);
         
         if (counted > 0) counted --;
         
         int limit = Bars - counted; 
  
         
         for (int i = 0; i < limit; i++)
         {
         
         double h1 = High[1];
         double h2 = High[2];
         double h3 = High[3];
         double h4 = High[4];
                  
         double l1 = Low[1];
         double l2 = Low[2];
         double l3 = Low[3];
         double l4 = Low[4];
                  
         double c1 = Close[1];
         double c2 = Close[2];
         double c3 = Close[3];
         double c4 = Close[4];
                 
         pivot1[i] = (h1 + l1 + c1)/3;
         double pivot2 = (h2 + l2 + c2)/3;
         double pivot3 = (h3 + l3 + c3)/3;
         double pivot4 = (h4 + l4 + c4)/3;
         
         curAvg[i] = (pivot2 + pivot3 + pivot4)/3;
         
         }

        
  }


 
Duh -- Sorry i figured it out. Was that i didn't use I within the high close and low deals. Thanx