Buffer Drawing

 
I´m modifying some pivot indicator to display weekly values but I can´t manage to draw the buffers.

The values are calculed correctly and the labels are good too.

What I´m doing wrong :(

Thanks in advance.

Here´s the code

#define IND_NAME "Weekly Pivot S&R"
#property indicator_buffers 7
#property indicator_chart_window
#property indicator_color1 Green
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Blue
#property indicator_color5 Red
#property indicator_color6 Blue
#property indicator_color7 Red
 
extern int TimeZone=0;
extern bool Labels = true;
 
double PivotBuffer[];
double s1buffer[];
double r1buffer[];
double s2buffer[];
double r2buffer[];
double s3buffer[];
double r3buffer[];
double day_high=0;
double day_low=0;
double yesterday_high=0;
double yesterday_open=0;
double yesterday_low=0;
double yesterday_close=0;
double today_open=0;
double today_high=0;
double today_low=0;
double P=0;
double Q=0;
double R1,R2,R3;
double S1,S2,S3;
double nQ=0;
double nD=0;
double D=0;
double rates_h1[2][6];
double rates_d1[2][6];
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,0,2);
   SetIndexStyle(1,DRAW_LINE,0,2);
   SetIndexStyle(2,DRAW_LINE,0,2);
   SetIndexStyle(3,DRAW_LINE,0,2);
   SetIndexStyle(4,DRAW_LINE,0,2);
   SetIndexStyle(5,DRAW_LINE,0,2);
   SetIndexStyle(6,DRAW_LINE,0,2);
   SetIndexBuffer(0,PivotBuffer);
   SetIndexBuffer(1,s1buffer);
   SetIndexBuffer(2,r1buffer);
   SetIndexBuffer(3,s2buffer);
   SetIndexBuffer(4,r2buffer);
   SetIndexBuffer(5,s3buffer);
   SetIndexBuffer(6,r3buffer);
   
   IndicatorShortName(IND_NAME);
//----
 
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
ObjectDelete("R1 Label"); 
ObjectDelete("R2 Label");
ObjectDelete("R3 Label");
ObjectDelete("S1 Label");
ObjectDelete("S2 Label");
ObjectDelete("S3 Label");
ObjectDelete("P Label");
 
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
      int i=0, j=0;
//---- TODO: add your code here
 
//---- exit if period is greater than daily charts
if(Period() > 1440)
{
Print("Error - Chart period is greater than 1 day.");
return(-1); // then exit
}
 
//---- Get new daily prices
 
ArrayCopyRates(rates_d1, Symbol(), PERIOD_W1);
yesterday_high = rates_d1[1][3];
yesterday_low = rates_d1[1][2]; 
day_high = rates_d1[0][3];
day_low = rates_d1[0][2];
 
ArrayCopyRates(rates_h1, Symbol(), PERIOD_W1);
for (i=0;i<=25;i++)
{
   if (TimeMinute(rates_h1[i][0])==0 && (TimeHour(rates_h1[i][0])-TimeZone)==0)
   {
      yesterday_close = rates_h1[i+1][4];      
      yesterday_open = rates_h1[i+24][1];
      today_open = rates_h1[i][1];      
      break;
   }
}
 
//---- Calculate Pivots
 
D = (day_high - day_low);
Q = (yesterday_high - yesterday_low);
P = (yesterday_high + yesterday_low + yesterday_close) / 3;
R1 = (2*P)-yesterday_low;
S1 = (2*P)-yesterday_high;
R2 = P+(yesterday_high - yesterday_low);
S2 = P-(yesterday_high - yesterday_low);
R3 = (2*P)+(yesterday_high-(2*yesterday_low));
S3 = (2*P)-((2* yesterday_high)-yesterday_low);
 
PivotBuffer[i]=P;
r3buffer[i]=R3;
r2buffer[i]=R2;
r1buffer[i]=R1;
s1buffer[i]=S1;
s2buffer[i]=S2;
s3buffer[i]=S3;
 
 
if (Q > 5) 
{
    nQ = Q;
}
else
{
    nQ = Q*10000;
}
 
if (D > 5)
{
    nD = D;
}
else
{
    nD = D*10000;
}
 
 
Comment("High= ",yesterday_high,"    Previous Days Range= ",nQ,"\nLow= ",yesterday_low,"    Current Days Range= ",nD,"\nClose= ",yesterday_close,"\nOpen= ",yesterday_open);
 
//
 
 
   if (Labels==true)
   {
      if(ObjectFind("R1 label") != 0)
      {
      ObjectCreate("R1 label", OBJ_TEXT, 0, Time[20], R1);
      ObjectSetText("R1 label", " R1", 8, "Arial", Black);
      }
      else
      {
      ObjectMove("R1 label", 0, Time[20], R1);
      }      
      if(ObjectFind("R2 label") != 0)
      {
      ObjectCreate("R2 label", OBJ_TEXT, 0, Time[20], R2);
      ObjectSetText("R2 label", " R2", 8, "Arial", Black);
      }
      else
      {
      ObjectMove("R2 label", 0, Time[20], R2);
      }
      if(ObjectFind("R3 label") != 0)
      {
      ObjectCreate("R3 label", OBJ_TEXT, 0, Time[20], R3);
      ObjectSetText("R3 label", " R3", 8, "Arial", Black);
      }
      else
      {
      ObjectMove("R3 label", 0, Time[20], R3);
      }
 
      if(ObjectFind("P label") != 0)
      {
      ObjectCreate("P label", OBJ_TEXT, 0, Time[20], P);
      ObjectSetText("P label", "Pivot", 8, "Arial", Black);
      }
      else
      {
      ObjectMove("P label", 0, Time[20], P);
      }
      if(ObjectFind("S1 label") != 0)
      {
      ObjectCreate("S1 label", OBJ_TEXT, 0, Time[20], S1);
      ObjectSetText("S1 label", "S1", 8, "Arial", Black);
      }
      else
      {
      ObjectMove("S1 label", 0, Time[20], S1);
      } 
      if(ObjectFind("S2 label") != 0)
      {
      ObjectCreate("S2 label", OBJ_TEXT, 0, Time[20], S2);
      ObjectSetText("S2 label", "S2", 8, "Arial", Black);
      }
      else
      {
      ObjectMove("S2 label", 0, Time[20], S2);
      }
      if(ObjectFind("S3 label") != 0)
      {
      ObjectCreate("S3 label", OBJ_TEXT, 0, Time[20], S3);
      ObjectSetText("S3 label", "S3", 8, "Arial", Black);
      }
      else
      {
      ObjectMove("S3 label", 0, Time[20], S3);
      }
 
 
   }//
 
 
//---- End Of Program
   return(0);
  }
//+------------------------------------------------------------------+
 
it seems you are populating your buffers outside of the loop. In fact I don't think you have any loop to populate your buffers.
Reason: