[Zorro] Possible bug in ATRS in include.c

Posted By: Mithrandir77

[Zorro] Possible bug in ATRS in include.c - 09/11/14 21:22

I was digging in indicators.c when I spotted a possibly error in the implementation of the ATRS indicator:

Code:
// Simple ATR based on SMA
var ATRS(int Period)
{
	Period = max(1,Period);
	var vATRS =  0;
	for(g_count = 0; g_count < Period; g_count++)
		vATRS = priceHigh(g_count)-priceLow(g_count);
	return vATRS/Period;
}



Shouldn't it be inside the for

Code:
vATRS += priceHigh(g_count)-priceLow(g_count);



? because in the present version it is not adding up the ATR ranges, only the last one is returned.
Posted By: jcl

Re: [Zorro] Possible bug in ATRS in include.c - 09/12/14 08:22

Thanks, this was indeed a bug and will be fixed in the next release.

Workaround: Copy the ATRS code in your script, rename the function to "ATRS_Fixed", and replace the = with a += in the for loop.
© 2024 lite-C Forums