コード例 #1
0
        public static DirectionalIndicatorMinus Create(int periods)
        {
            AverageDirectionalMovementMinus admMinus = AverageDirectionalMovementMinus.Create(periods);
            AverageTrueRange atr = AverageTrueRange.Create(periods);

            double Function(CandleTimeSeries series, DateTime instant)
            {
                return(admMinus[series, instant].DivideBy(atr[series, instant]));
            }

            DirectionalIndicatorMinus result = new DirectionalIndicatorMinus(Function);

            return(result);
        }
コード例 #2
0
        public static AverageDirectionalMovementMinus Create(
            int periods
            )
        {
            DirectionalMovementMinus dmMinus = DirectionalMovementMinus.Create( );

            double Function(CandleTimeSeries series, DateTime instant)
            {
                Candle candle = series[instant];
                int    index  = series.GetIndex(candle);

                Candle[] candles = index.GetIntegersTo(Math.Max(1, index - periods))
                                   .Select(idx => series[idx])
                                   .ToArray( );
                double ema = candles
                             .WeightedAverage((cdl, idx) => dmMinus[series, cdl.Start], (cdl, idx) => candles.Length - idx);

                return(ema);
            }

            AverageDirectionalMovementMinus plus = new AverageDirectionalMovementMinus(Function);

            return(plus);
        }