Average body candle wrong calculation!

 

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,

 
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);
  }
 
Konstantin Nikitin:

Thanks man!


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

string getName()
{
   return Stupd.ME;
}

getName();
Reason: