if (CurrentBar == 0)
Value.Set(Input[0]);
else
{
double last = Value[1] * Math.Min(CurrentBar, Period);
if (CurrentBar >= Period)
Value.Set((last + Input[0] - Input[Period]) / Math.Min(CurrentBar, Period));
else
Value.Set((last + Input[0]) / (Math.Min(CurrentBar, Period) + 1));
}
So, for example, if the Period=14, and CurrentBar=15, SMA=(Value[1]*14+Input[0]-InPut[14])/14 . Then, instead of adding up the last 14 bars, it just simply use the Value*14 ?
It seems quite confused to me, any suggestion ?
Comment