Download MetaTrader 5

Count bar above mid point of 5 days

To add comments, please log in or register
hhchenfx
976
hhchenfx  

Hi Everyone,

I am trying to count the number of bar (within the 5 bars) that are above the mid point.

This code does not work for me and I cannot find where it goes wrong.

Could you please help me with that?

Thank you so much.

HHCFX

   for (i=1; i<=limit; i++) 
   {  
      double mid=(Open[i]+Open[i+4])/2;
      
      count=0;

      for(k=i;k<=i+4;k++);
      {
         if(Close[k]>mid) t=1;else t=0;
         count=count+t;
      }

      numberbar[i]=count;
Alain Verleyen
Moderator
32833
Alain Verleyen  
hhchenfx:

Hi Everyone,

I am trying to count the number of bar (within the 5 bars) that are above the mid point.

This code does not work for me and I cannot find where it goes wrong.

Could you please help me with that?

Thank you so much.

HHCFX

What "doesn't work" means in this case ?
To add comments, please log in or register