|
|
哪位大神帮我把下面这个SMA函数改成DMA函数,
DMA(C,N): DMA算法:Y=C*N+Y'*(1-N)
感谢
double SmoothedMA(const int position,const int period,const double prev_value,const double &price[])
{
double result=0.0;
//--- check period
if(period>0 && period<=(position+1))
{
if(position==period-1)
{
for(int i=0; i<period; i++)
result+=price[position-i];
result/=period;
}
result=(prev_value*(period-1)+price[position])/period;
}
return(result);
} |
|