Author: Mladen Rakic
double avgx = (period-1) * 0.5;
Which if the original line is correct, should be more concise and faster, especially if it's done
before entering the for() loop, because it doesn't rely on any changes inside the loop.
I suspect it could be a typo
Oh, I see your logic now, how could I have doubted it???
SumX = period * (period-1)/2;
and then to get average X for each idx you divide it by the period.
So, leaving it as you have coded it makes it clearer that avgx is actually the average of SumX.
Sorry to bother you unduly, it's a great indicator.
Best regards, Paul Kelly.