Esempio n. 1
0
        public Statistic GetStatistic()
        {
            List <IEnumerable <DateTime> > groups = ProvidersUtils.GetGroupedPatches(dx, adx, diPlus, diMinus)
                                                    .ToList();
            List <IEnumerable <DateTime> > upGroups = groups
                                                      .Where(g => ProvidersUtils.IsUpTendency(g, diPlus, diMinus))
                                                      .ToList();
            IEnumerable <DateTime> upGroupMaxCandles = upGroups.Any()
                ? upGroups.MaxBy(group => ProvidersUtils.GetPriceVariation(group.ToList(), candleSeries))
                : null;
            List <IEnumerable <DateTime> > downGroups = groups
                                                        .Where(g => ProvidersUtils.IsDownTendency(g, diPlus, diMinus))
                                                        .ToList();
            IEnumerable <DateTime> downGroupMaxCandles = downGroups.Any()
                ? downGroups.MaxBy(group => - ProvidersUtils.GetPriceVariation(group.ToList(), candleSeries, upTendency: false))
                : null;

            double upPriceVariation = upGroupMaxCandles != null
                ? ProvidersUtils.GetPriceVariation(upGroupMaxCandles.ToList(), candleSeries)
                : 0;

            double downPriceVariation = downGroupMaxCandles != null
                ? ProvidersUtils.GetPriceVariation(downGroupMaxCandles.ToList(), candleSeries, upTendency : false)
                : 0;

            return(new Statistic("Price variation adx positive slope"
                                 , upPriceVariation
                                 , downPriceVariation));
        }
        public Statistic GetStatistic()
        {
            List <IEnumerable <DateTime> > patches = ProvidersUtils.GetGroupedPatches(dx, adx, diPlus, diMinus)
                                                     .ToList();
            double benefitUp = patches
                               .Where(patch => ProvidersUtils.IsUpTendency(patch, diPlus, diMinus))
                               .Sum(patch => ProvidersUtils.GetPriceVariation(patch.ToList(), series));
            double benefitDown = patches
                                 .Where(patch => ProvidersUtils.IsDownTendency(patch, diPlus, diMinus))
                                 .Sum(patch => - ProvidersUtils.GetPriceVariation(patch.ToList(), series, false));

            return(new Statistic("Benefit", benefitUp, benefitDown));
        }
Esempio n. 3
0
        public Statistic GetStatistic()
        {
            List <IEnumerable <DateTime> > groups = ProvidersUtils.GetGroupedPatches(dx, adx, diPlus, diMinus).ToList();

            List <IEnumerable <DateTime> > upGroups = groups
                                                      .Where(g => ProvidersUtils.IsUpTendency(g, diPlus, diMinus))
                                                      .ToList();
            IEnumerable <DateTime> upGroupMaxCandles = upGroups.Any()
                ? upGroups.MaxBy(group => group.Count())
                : null;
            double upValue = upGroupMaxCandles?.Count() ?? 0;

            List <IEnumerable <DateTime> > downGroups = groups
                                                        .Where(g => ProvidersUtils.IsDownTendency(g, diPlus, diMinus))
                                                        .ToList();
            IEnumerable <DateTime> downGroupMaxCandles = downGroups.Any()
                ? downGroups.MaxBy(group => group.Count())
                : null;
            double downValue = downGroupMaxCandles?.Count() ?? 0;

            return(new Statistic("# Candle Adx positive slope"
                                 , upValue
                                 , downValue));
        }