Why doesn't this work? Thanks

 
Learning to draw on the chart, I find that this works:

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1  Gold
#property indicator_width1 2
#property indicator_color2  Green
#property indicator_width2 2
#property indicator_color3  Red
#property indicator_width3 1
 
#define UP                  1
#define DOWN                2
 
extern int showDogis      = 1;     // 1 = Show a star for Dogis
extern int showArrows     = 1;     // 1 = Arrows for morning and evening Dogi stars
 
double dogiBuffer[];
double upBuffer[];
double downBuffer[];
int offset = 2;
/*
 * Initialization function
 */
int init() {
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexStyle(2, DRAW_ARROW);
   SetIndexArrow(0, 171); // draw a star
   SetIndexArrow(1, 241); // old value = 225 = up arrow
   SetIndexArrow(2, 242); // old value = 226 = down arrow
   SetIndexBuffer(0, dogiBuffer);
   SetIndexBuffer(1, upBuffer);
   SetIndexBuffer(2, downBuffer);
   SetIndexLabel(0, "Dogi");
   SetIndexLabel(1, "Up Signal");
   SetIndexLabel(2, "Down Signal");
   return(0);
}
 
/*
 * Main program
 */
int start() 
{
//Alert("in start");
   int i, dogiVal;
   int counted_bars = IndicatorCounted();
   // Loop and look for pivots
   for(i = Bars - counted_bars; i >= 0; i--) 
   {
   dogiBuffer[i] = Low[i] - offset * Point;
   upBuffer[i + 1] = Low[i + 1] - offset * Point;
   downBuffer[i + 1] = High[i + 1] + offset * Point;
 
   }
 
   return(0);
}

But then why doesn't this one also work, only difference is the addition of some extra logic?

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1  White
#property indicator_width1 2
#property indicator_color2  White
#property indicator_width2 2
#property indicator_color3  White
#property indicator_width3 1
 
double buyBuffer[];
double sellBuffer[];
double labelBuffer[];
int offset = 1;
/*
 * Initialization function
 */
int init() {
   offset = 2;
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexStyle(2, DRAW_ARROW); //////---------------------------
   SetIndexArrow(0, 171); // draw a star
   SetIndexArrow(1, 242); // old value = 225 = up arrow
   SetIndexArrow(2, 242); // old value = 226 = down arrow ------------
   SetIndexBuffer(0, buyBuffer);
   SetIndexBuffer(1, sellBuffer);
   SetIndexBuffer(2, labelBuffer);//---------------------
   SetIndexLabel(0, "buy");
   SetIndexLabel(1, "sell");
   SetIndexLabel(2, "label");//---------------
   return(0);
}
int start() 
{
   int i, pips;
   int counted_bars = IndicatorCounted();
   double diff, ab_diff,val,myPoints;
   double first_price,cur_price = Close[Bars-1];
   double ab,va;
   for(i = Bars-1; i >= 0; i--) 
   {///////////////////////////////////////////       
      va = MathAbs( first_price - Close[i]);
      ab = (MathAbs(first_price - Close[i]))/Point;
      if(ab>=5 && va==1) {buyBuffer[i] = High[i + 1]+offset*Point; first_price = Close[i];}
      if(ab>=5 && va<-1) {sellBuffer[i]= Low[ i    ]-offset*Point; first_price = Close[i];}     
   }//////////////////////////////////////////////   
   return(0);
}

Thanks so much. I hope someone can clarify this.
Steve


 
oh, I see it should have been this, looking at va<0 or >0

     if(ab>=5 && va>0) {buyBuffer[i] = High[i + 1]+offset*Point; first_price = Close[i];}
     if(ab>=5 && va<0) {sellBuffer[i]= Low[ i    ]-offset*Point; first_price = Close[i];}
Reason: