Need help making first indicator pl0x

 

Hi, as the subject states, i need help making my first custom indicator =(. i am trying to make an indicator (out of curiosity purposes) on simplistic probability using binomial distribution theory...here's the code:

int start()

{

int i,counted_bars=IndicatorCounted();

//----

if(Bars<=MomPeriod) return(0);

//---- initial zero

if(counted_bars<1)

for(i=1;i<=MomPeriod;i++) Buffer_Main[Bars-i]=0.0;

//----

i=Bars-MomPeriod-1;

if(counted_bars>=MomPeriod) i=Bars-counted_bars-1;

while(i>=0)

{

Buffer_Main[-1]=0.0;

if(Open[i] > Close[i])

{

Buffer_Main[i]=Buffer_Main[i-1] - (100 - (Buffer_Main[i-1]*2));

return;

}

if(Open[i] < Close[i])

{

Buffer_Main[i]=Buffer_Main[i-1] + (100 - (Buffer_Main[i-1]/2));

return;

}

i--;

}

//----


//----

return(0);

}


I'm not sure what it is exactly that I'm doing wrong but, to specificy, what i would like to have happen is this: starting at the beginning of the week i would like to have a rolling counter of the probability of positive and negative candles occuring (assuming 50% chance per each and ignoring neutral candles). so that if you start out at 0 and a positive candle comes, you are now at 50%, if another positive candle comes you are at 75%, if a negative candle comes you are at 25%--the +/- indicating positive or negative candles or up or down, etc. anyways, any help would be greatly appreciated, im pulling my hair out =(

Reason: