0.0714 always? - center of gravity on iCustom tick

 
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 White
double price[],cog[],draw[],SA,SB;
int B,N,C,inc=0;
int init(){return(0);}
int start(){
      IndicatorBuffers(1);
      SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,White);
      SetIndexBuffer(0,draw);
      if(price[0]!=Close[0]){
         if(B<Bars){B=Bars;ArrayInitialize(price,EMPTY_VALUE);ArrayInitialize(cog,EMPTY_VALUE);ArrayInitialize(draw,EMPTY_VALUE);inc=0;}else{inc++;}
         ArraySetAsSeries(price,true);
         ArrayResize(price,inc);
         ArraySetAsSeries(cog,true);
         ArrayResize(cog,inc);
         
         for(N=inc-2;N>=0;N--){
            price[N+1]=price[N];
            if(N==0){price[N]=iCustom(NULL,0,"e",0,N);}
            }
         
         for(N=inc-15;N>=0;N--){
            cog[N+1]=cog[N];
            for(C=0;C<=13;C++){SA=(price[N+C])/2;SB=((price[N+C])*(C+1)/2);}
            if(N==0){cog[N]=SA/SB;Comment(cog[N]);}
            if(N!=inc-15){draw[N]=cog[N];}
            }
         }
      return(0);
      }

Comment shows 0.0714 always, why? this center of gravity calculation works on normal indicators! I have been successful in getting iCustom to display ticks only for the current bar and i am following rules to never display empty values.

If I do:

SA=SA+(price[N+C])/2;SB=SB+((price[N+C])*(C+1)/2);

the indicator only increases. I fail to see what is wrong here. Can you spot my mistake?

 
  1. IndicatorBuffers(1);
    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,White);
    SetIndexBuffer(0,draw);
    Belongs in init so the array can be resized before the call to start
  2.   if(B<Bars){B=Bars;ArrayInitialize(price,EMPTY_VALUE);ArrayInitialize(cog,EMPTY_VALUE);...
         
    
    How could you initialize those arrays, when you havn't resized them yet?
Reason: