/// <summary> /// Получить набор значений TrueRange для массива свечек. /// </summary> /// <param name="bars">Исходный набор свечек.</param> /// <returns>Набор результирующих значений TrueRange для всех свечей из исходного набора.</returns> public static IEnumerable <double> Values(IEnumerable <Bar> bars) { int count = bars.Count(); double[] result = new double[count]; if (count == 0) { return(result); } for (int i = 0; i < count; i++) { result[i] = TrueRange.Value(bars, i); } return(result); }
public static double Value(IEnumerable <Bar> bars) { int count = bars.Count(); if (count == 0) { return(0); } double[] trs = new double[count]; for (int i = 0; i < count; i++) { trs[i] = TrueRange.Value(bars, i); } return(Math.Round(trs.Average(), 4)); }
public static IEnumerable <double> Values(IEnumerable <Bar> collection, int period) { int count = collection.Count(); double[] result = new double[count]; if (count < period) { return(result); } IEnumerable <double> trueRanges = TrueRange.Values(collection); double[] wilderMA = WilderMA.Values(trueRanges, period).ToArray(); for (int i = 0; i < count; i++) { result[i] = wilderMA[i]; } return(result); }