/* MACD */

        private static MacdResult MACD(List <Candle> candles,
                                       MovingAverageType fastMaType,
                                       int fastPeriod,
                                       MovingAverageType slowMaType,
                                       int slowPeriod,
                                       MovingAverageType signalMaType,
                                       int signalPeriod,
                                       IndicatorCalculationBase calculationBase = IndicatorCalculationBase.Close,
                                       Func <decimal[], decimal[], decimal[], IndicatorSignal> signalLogic = null)
        {
            decimal[] input;
            if (calculationBase == IndicatorCalculationBase.Close)
            {
                input = candles.Select(c => c.Close).ToArray();
            }

            else if (calculationBase == IndicatorCalculationBase.Open)
            {
                input = candles.Select(c => c.Open).ToArray();
            }

            else if (calculationBase == IndicatorCalculationBase.High)
            {
                input = candles.Select(c => c.High).ToArray();
            }

            else if (calculationBase == IndicatorCalculationBase.Low)
            {
                input = candles.Select(c => c.Low).ToArray();
            }

            else if (calculationBase == IndicatorCalculationBase.Volume)
            {
                input = candles.Select(c => c.Volume).ToArray();
            }

            else
            {
                input = candles.Select(c => c.Close).ToArray();
            }

            return(MACD(input, fastMaType, fastPeriod, slowMaType, slowPeriod, signalMaType, signalPeriod, signalLogic));
        }
        /* MA */

        private static MovingAverageResult MA(List <Candle> candles,
                                              MovingAverageType maType,
                                              int period,
                                              IndicatorCalculationBase calculationBase = IndicatorCalculationBase.Close,
                                              Func <decimal[], decimal[], IndicatorSignal> signalLogic = null)
        {
            decimal[] input;
            if (calculationBase == IndicatorCalculationBase.Close)
            {
                input = candles.Select(c => c.Close).ToArray();
            }

            else if (calculationBase == IndicatorCalculationBase.Open)
            {
                input = candles.Select(c => c.Open).ToArray();
            }

            else if (calculationBase == IndicatorCalculationBase.High)
            {
                input = candles.Select(c => c.High).ToArray();
            }

            else if (calculationBase == IndicatorCalculationBase.Low)
            {
                input = candles.Select(c => c.Low).ToArray();
            }

            else if (calculationBase == IndicatorCalculationBase.Volume)
            {
                input = candles.Select(c => c.Volume).ToArray();
            }

            else
            {
                input = candles.Select(c => c.Close).ToArray();
            }

            return(MA(input, maType, period, signalLogic));
        }
        /* B_BANDS */

        private static BollingerBandsResult B_BANDS(List <Candle> candles,
                                                    int period,
                                                    double stdDevUp,
                                                    double stdDevDown,
                                                    MovingAverageType maType,
                                                    IndicatorCalculationBase calculationBase = IndicatorCalculationBase.Close,
                                                    Func <decimal[], decimal[], decimal[], decimal[], IndicatorSignal> signalLogic = null)
        {
            decimal[] input;
            if (calculationBase == IndicatorCalculationBase.Close)
            {
                input = candles.Select(c => c.Close).ToArray();
            }

            else if (calculationBase == IndicatorCalculationBase.Open)
            {
                input = candles.Select(c => c.Open).ToArray();
            }

            else if (calculationBase == IndicatorCalculationBase.High)
            {
                input = candles.Select(c => c.High).ToArray();
            }

            else if (calculationBase == IndicatorCalculationBase.Low)
            {
                input = candles.Select(c => c.Low).ToArray();
            }

            else
            {
                input = candles.Select(c => c.Close).ToArray();
            }

            return(B_BANDS(input, period, stdDevUp, stdDevDown, maType, signalLogic));
        }
 public static MovingAverageResult Wma(List <Candle> input, int period, IndicatorCalculationBase calculationBase, Func <decimal[], decimal[], IndicatorSignal> signalLogic)
 {
     return(Indicators.MA(input, MovingAverageType.Wma, period, calculationBase: calculationBase, signalLogic: signalLogic));
 }
 public static RsiResult Rsi(List <Candle> input, int period, IndicatorCalculationBase calculationBase)
 {
     return(RSI(input, period, calculationBase: calculationBase));
 }
 public static MovingAverageResult Wma(List <Candle> input, int period, IndicatorCalculationBase calculationBase)
 {
     return(Indicators.MA(input, MovingAverageType.Wma, period, calculationBase: calculationBase));
 }
 public static MacdResult Macd(List <Candle> input, int fastPeriod, int slowPeriod, int signalPeriod, IndicatorCalculationBase calculationBase, Func <decimal[], decimal[], decimal[], IndicatorSignal> signalLogic)
 {
     return(Indicators.MACD(input, MovingAverageType.Ema, fastPeriod, MovingAverageType.Ema, slowPeriod, MovingAverageType.Ema, signalPeriod, calculationBase: calculationBase, signalLogic: signalLogic));
 }
 public static MacdResult Macd(List <Candle> input, int fastPeriod, int slowPeriod, int signalPeriod, IndicatorCalculationBase calculationBase)
 {
     return(Indicators.MACD(input, MovingAverageType.Ema, fastPeriod, MovingAverageType.Ema, slowPeriod, MovingAverageType.Ema, signalPeriod, calculationBase: calculationBase));
 }
 public static MacdResult ExtendedMacd(List <Candle> input, MovingAverageType fastMaType, int fastPeriod, MovingAverageType slowMaType, int slowPeriod, MovingAverageType signalMaType, int signalPeriod, IndicatorCalculationBase calculationBase)
 {
     return(Indicators.MACD(input, fastMaType, fastPeriod, slowMaType, slowPeriod, signalMaType, signalPeriod, calculationBase: calculationBase));
 }
 public static BollingerBandsResult BollingerBands(List <Candle> input, int period, double standardDeviationUp, double standardDeviationDown, MovingAverageType maType, IndicatorCalculationBase calculationBase, Func <decimal[], decimal[], decimal[], decimal[], IndicatorSignal> signalLogic)
 {
     return(B_BANDS(input, period, standardDeviationUp, standardDeviationDown, maType, calculationBase: calculationBase, signalLogic: signalLogic));
 }
 public static BollingerBandsResult BollingerBands(List <Candle> input, int period, double standardDeviationUp, double standardDeviationDown, MovingAverageType maType, IndicatorCalculationBase calculationBase)
 {
     return(B_BANDS(input, period, standardDeviationUp, standardDeviationDown, maType, calculationBase: calculationBase));
 }