Trouble calculating average

 
This always results in 0, no matter what the market does.  What is going on?
//find average body over the last 12 1 minute bars
for(int j=12;j>=0;j--)
{
   BodyAve += MathAbs(Open[j]-Close[j]);   
   Count++;
   BodyAve = BodyAve/Count;  
}
 

You didn't show all your code.

try making Count a double instead of an int

 

I tried:

double Count = 1;

Still nothing but 0.


The rest of the code is pretty inconsequential:

Comment("BodyAve: ",BodyAve);

Previously I also tried this:

for(int j=12;j>=0;j--)

{
BodyAve += MathAbs(Open[j]-Close[j]);
}

BodyAve = BodyAVe/12;

Then I got 0.0001 all the time.

 

"The rest of the code is pretty inconsequential"

Well, it is necessary. Good luck.

 

phy speaks truth, each keypress is always the most consequential datum of every statement. no such thing as inconsequential code.

guess what? that code is most likely the clue or the issue as to why you not get what you expect.

Do self big favour: insert Print()'s into code and I mean at every step taken as you are obviously using some combo of: ints,doubles and mql's default rounding/chopping

is not rocket science - just expose each calculation so that you can get a handle on what each statement is doing.

"What is going on?" will then be staring you in face.

have fun...

Reason: