using System; using System.Drawing; using System.Linq; using System.Collections; namespace PowerLanguage { namespace Function { public class MyAvg { public static double Avg(ArrayList list,int length) { if(list.Count < length ) return 0.0 ; double all = 0.0 ; for(int i = list.Count - length ; i< list.Count; i++) { all += (Double)list[i]; } if(list.Count >0) { return all/length; } return 0.0 ; } public static ArrayList ma(ArrayList price, int length,int limit) { if (price.Count < length) return null; if (length + limit-1 > price.Count) return null; ArrayList temparray = new ArrayList(); for (int i = 0; i < length+limit-1; i++) { if (i < length - 1) continue; double temp = 0; for (int j = i; j > i - length; j--) { temp += (double)price[j]; } temparray.Add(temp / length); Console.WriteLine("---------------------" + temp); } return temparray; } } } }