having problems =(

 

Hi,

I am having problems coding my first custom indicator. ye i know this forum gets a lot of these posts, sorry =(. Basically, what I am aiming for is for this indicator to give me a certain probability, so to speak, of what the how the next candle will behave--based upon the data that I have gathered through the indicator as well as the formulas. What I "think" I have done so far is, gathered the number of positive and negative candles on the chart and then depending on how many positive candles occur in a row, made the indicator display the probability. problem is, it doesn't show up at all, and i'm pretty much completely lost. I've been working on this for days and have scratched countless codes. Any help would be greatly appreciated. Thanks! (attached is the code).

Files:
 
basefree:

Hi,

I am having problems coding my first custom indicator. ye i know this forum gets a lot of these posts, sorry =(. Basically, what I am aiming for is for this indicator to give me a certain probability, so to speak, of what the how the next candle will behave--based upon the data that I have gathered through the indicator as well as the formulas. What I "think" I have done so far is, gathered the number of positive and negative candles on the chart and then depending on how many positive candles occur in a row, made the indicator display the probability. problem is, it doesn't show up at all, and i'm pretty much completely lost. I've been working on this for days and have scratched countless codes. Any help would be greatly appreciated. Thanks! (attached is the code).

int start()
  {
   int i,q,counted_bars=IndicatorCounted();
//----
   i=Bars-counted_bars-1;
   int PosBars=0;
   int NegBars=0;
   
   for(q=0;q<=i;q++)
   {
      if(Open[q]<Close[q])
         PosBars++;
      if(Open[q]>Close[q])
         NegBars++;
   }
   
   double ProbabilityPos=PosBars/i;

The first time this will run fine. On the next tick, i==0 and you only get either posbars=1 or negbars=1

Either loop over 1..Bars-1 always, or you need to make those int's static

 
great! thank you very much for your help. I will give this a shot!
Reason: