Average body candle wrong calculation!

To add comments, please log in or register
Iulian Astalus
36
Iulian Astalus  

Hello,


I have the following code:

double total =0;
void OnTick()
{
        if(Volume[0] ==1)
        {
           Print(CalculateAv());
        }
}  
int calculateAv()
  {     
      for(i==1;i<=10;i++)
      {
         total = total + MathAbs(iClose(NULL,PERIOD_M15,i) - iOpen(NULL,PERIOD_M15,i));
      }
      Print ("Total =" + total); // this is WRONG!!!
      return MathRound(total/10);
  }

I don't understand what's wrong with it.The problem occurs when the total amount of last 10 candles is calculated.

Please help!


Thanks,

Konstantin Nikitin
8352
Konstantin Nikitin  
double calculateAv(void)
  {     
      double total = 0;
      for(int i=1; i<=10; i++)
      {
         total += MathAbs(iClose(NULL,PERIOD_M15,i) - iOpen(NULL,PERIOD_M15,i));
      }
      Print ("Total =" + DoubleToString(total, _Digits)); // this is WRONG!!!
      return MathRound(total/10);
  }
Iulian Astalus
36
Iulian Astalus  
Konstantin Nikitin:

Thanks man!


static class Stupid
{
   public static string ME="Iulian";
}

string getName()
{
   return Stupd.ME;
}

getName();
To add comments, please log in or register