public ITaLibOutput <double[]> HilbertTransformDominantCyclePeriod(Frequency unitType, int historiesLength)
        {
            var inputs = new IndicatorsInputs(database, historiesLength);

            database.FillMarketHistory(unitType, inputs.OutputArrayLength);

            double[] closingHistory = database.CurrentHistory
                                      .Select(bar => bar.ClosingPrice)
                                      .ToArray();

            var output = new TaLibOutput <double[]> {
                Series           = new double[inputs.OutputArrayLength],
                HistoryWasCustom = database.HistoryIsCustom
            };
            int outBeginningIndex = 0;
            int outNBElement      = 0;

            output.Outcome = Core.HtDcPeriod(startIdx: inputs.StartingIndex,
                                             endIdx: inputs.EndIndex,
                                             inReal: closingHistory,
                                             outBegIdx: out outBeginningIndex,
                                             outNBElement: out outNBElement,
                                             outReal: output.Series);

            output.AlgorithmsBeginningIndex = outBeginningIndex;
            output.NBElement = outNBElement;
            return(output);
        }
Пример #2
0
        public ITaLibOutput <double[]> Beta(Frequency unitType, int historiesLength, int timePeriod = 5)
        {
            var inputs = new IndicatorsInputs(database, historiesLength);

            database.FillMarketHistory(unitType, inputs.OutputArrayLength);

            double[] highs = database.CurrentHistory
                             .Select(bar => bar.PriceHigh)
                             .ToArray();

            double[] lows = database.CurrentHistory
                            .Select(bar => bar.PriceLow)
                            .ToArray();

            var output = new TaLibOutput <double[]> {
                Series           = new double[inputs.OutputArrayLength],
                HistoryWasCustom = database.HistoryIsCustom
            };
            int outBeginningIndex = 0;
            int outNBElement      = 0;

            output.Outcome = Core.Beta(startIdx: inputs.StartingIndex,
                                       endIdx: inputs.EndIndex,
                                       inReal0: highs,
                                       inReal1: lows,
                                       optInTimePeriod: timePeriod,
                                       outBegIdx: out outBeginningIndex,
                                       outNBElement: out outNBElement,
                                       outReal: output.Series);
            output.AlgorithmsBeginningIndex = outBeginningIndex;
            output.NBElement = outNBElement;
            return(output);
        }
        public ITaLibOutput <double[]> AveragePrice(Frequency unitType, int historiesLength)
        {
            var inputs = new IndicatorsInputs(database, historiesLength);

            database.FillMarketHistory(unitType, inputs.OutputArrayLength);

            double[] opens = database.CurrentHistory
                             .Select(bar => bar.OpeningPrice)
                             .ToArray();

            double[] highs = database.CurrentHistory
                             .Select(bar => bar.PriceHigh)
                             .ToArray();

            double[] lows = database.CurrentHistory
                            .Select(bar => bar.PriceLow)
                            .ToArray();

            double[] closes = database.CurrentHistory
                              .Select(bar => bar.ClosingPrice)
                              .ToArray();

            var output = new TaLibOutput <double[]> {
                Series           = new double[inputs.OutputArrayLength],
                HistoryWasCustom = database.HistoryIsCustom
            };
            int outBeginningIndex = 0;
            int outNBElement      = 0;

            output.Outcome = Core.AvgPrice(startIdx: inputs.StartingIndex,
                                           endIdx: inputs.EndIndex,
                                           inOpen: opens,
                                           inHigh: highs,
                                           inLow: lows,
                                           inClose: closes,
                                           outBegIdx: out outBeginningIndex,
                                           outNBElement: out outNBElement,
                                           outReal: output.Series);
            output.AlgorithmsBeginningIndex = outBeginningIndex;
            output.NBElement = outNBElement;
            return(output);
        }
Пример #4
0
        public ITaLibOutput <(double[] upperBand, double[] middleBand, double[] lowerBand)> BollingerBands(Frequency unitType, int historiesLength, Core.MAType movingAverageType = Core.MAType.Sma, int timePeriod = 5, int nbDevUp = 2, int nbDevDown = 2)
        {
            var inputs = new IndicatorsInputs(database, historiesLength);

            database.FillMarketHistory(unitType, inputs.OutputArrayLength);

            double[] closingHistory = database.CurrentHistory
                                      .Select(bar => bar.ClosingPrice)
                                      .ToArray();

            var output = new TaLibOutput <(double[] upperBand, double[] middleBand, double[] lowerBand)> {
                Series = (upperBand : new double[inputs.OutputArrayLength],
                          middleBand : new double[inputs.OutputArrayLength],
                          lowerBand : new double[inputs.OutputArrayLength]),
                HistoryWasCustom = database.HistoryIsCustom
            };
            int outBeginningIndex = 0;
            int outNBElement      = 0;

            output.Outcome = Core.Bbands(startIdx: inputs.StartingIndex,
                                         endIdx: inputs.EndIndex,
                                         inReal: closingHistory,
                                         optInTimePeriod: timePeriod,
                                         optInNbDevUp: nbDevUp,
                                         optInNbDevDn: nbDevDown,
                                         optInMAType: movingAverageType,
                                         outBegIdx: out outBeginningIndex,
                                         outNBElement: out outNBElement,
                                         outRealUpperBand: output.Series.upperBand,
                                         outRealMiddleBand: output.Series.middleBand,
                                         outRealLowerBand: output.Series.lowerBand);
            output.AlgorithmsBeginningIndex = outBeginningIndex;
            output.NBElement = outNBElement;
            return(output);
        }
Пример #5
0
        public ITaLibOutput <double[]> AbsolutePriceOscillator(Frequency unitType, int historiesLength, Core.MAType movingAverageType = Core.MAType.Sma, int slowPeriod = 26, int fastPeriod = 12)
        {
            var inputs = new IndicatorsInputs(database, historiesLength);

            database.FillMarketHistory(unitType, inputs.OutputArrayLength);

            double[] closingHistory = database.CurrentHistory
                                      .Select(bar => bar.ClosingPrice)
                                      .ToArray();

            var output = new TaLibOutput <double[]> {
                Series           = new double[inputs.OutputArrayLength],
                HistoryWasCustom = database.HistoryIsCustom
            };
            int outBeginningIndex = 0;
            int outNBElement      = 0;

            output.Outcome = Core.Apo(startIdx: inputs.StartingIndex,
                                      endIdx: inputs.EndIndex,
                                      inReal: closingHistory,
                                      optInFastPeriod: fastPeriod,
                                      optInSlowPeriod: slowPeriod,
                                      optInMAType: movingAverageType,
                                      outBegIdx: out outBeginningIndex,
                                      outNBElement: out outNBElement,
                                      outReal: output.Series);
            output.AlgorithmsBeginningIndex = outBeginningIndex;
            output.NBElement = outNBElement;
            return(output);
        }