统计学分析公式 MA移动平均线
算法代码实现
//统计学分析公式,指数平滑移动平均线 public decimal[] zhishupinghuayidongpingjunxian(decimal[] dec, int day) { if (day <= dec.Length) { decimal[] zs = new decimal[dec.Length ]; if (dec.Length > 0) { int d = 0; int js = 0; while (d < dec.Length ) { decimal he = 0; if (js == 0) { for (int i = 0; i < day; i++) { if ((i + d) <= dec.Length - 1) { he += dec[i + d]; } } try { zs[js] = (he / (decimal)day); } catch (Exception e) { string ssd = e.ToString(); } } else { zs[js] = (dec[d] * 1.00M) / (decimal)day + (zs[js - 1] * ((decimal)day - 1)) / (decimal)day; } ++d; js += 1; } } return zs; } else { return null; } }