That's simple but is there anyone who could tell me what's wrong with it...

 
int start()
{
 
   int counted_bars = IndicatorCounted(), limit, k, kperiods=100;
 
   if(Bars < kperiods) return(0);
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit = Bars - counted_bars - 1;
   
   for(int i=0; i<limit; i++)
   {
     k=1;
     if(iCustom(NULL, 0, "ZigZag", 12,4,3,0,i)!=0.0)
     {
       while(k<kperiods)
       {
         if(iCustom(NULL, 0, "ZigZag", 12,4,3,0,i+k)!=0.0)
         {
            break;
            while(k>i)
            {
              Delta[i+k+1]=iClose(NULL,0,i)/iClose(NULL,0,i+k+1)-1;
              k--;
            }
         }
         k++;  
       }
     }
   }
 
 return(0);     
}
... Can you catch why does it not return me any value? And you can grasp what it aims at, too?
 
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
 
for (int i=0; i < 100; i++)
{
  double ZZ = iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, i);
  Print("ZZ: ", i, "  ", ZZ);
}
 
RickD:
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
 
for (int i=0; i < 100; i++)
{
  double ZZ = iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, i);
  Print("ZZ: ", i, "  ", ZZ);
}


RickD,


I thank you sincerely. But what you posted does not help me. Am I not as/more smart as/than you expected? Don't know, could you please clarify your view? I tried your code but.. nothing clearer.


Thank you nonetheless,

SA

 
for ( int i = Bars ; i >=0; i -- )
 
DxdCn:
for ( int i = Bars ; i >=0; i -- )


OK. THANK YOU ALL. Thanks Rick and Thanks DxdCn. Now the matter is getting clearer and clearer. I guess it was a trick due to the direction of counter increments.

SA

Reason: