FastQuant.Indicators.ADX.Value C# (CSharp) Method

Value() public static method

public static Value ( ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio ) : double
input ISeries
index int
length int
style IndicatorStyle
return double
        public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
        {
            if (index >= 2 * length)
            {
                double num = 0.0;
                double result;
                if (style == IndicatorStyle.QuantStudio)
                {
                    for (int i = index; i > index - length; i--)
                    {
                        num += DX.Value(input, i, length, IndicatorStyle.QuantStudio);
                    }
                    result = num / (double)length;
                }
                else
                {
                    for (int j = 2 * length; j > length; j--)
                    {
                        num += DX.Value(input, j, length, style);
                    }
                    num /= (double)length;
                    for (int k = 2 * length + 1; k <= index; k++)
                    {
                        num = (num * (double)(length - 1) + DX.Value(input, k, length, style)) / (double)length;
                    }
                    result = num;
                }
                return result;
            }
            return double.NaN;
        }