Beispiel #1
0
        public override bool Identify(SecurityPrice price)
        {
            if (price != null && price.Index > 15)
            {
                IStatisticsCalculator calc = new StatisticCalculator(15);

                var dataPoints = calc.Calculate(price);
                //   Console.WriteLine(dataPoints.SU);
                if (price.Price < dataPoints.Mean - Math.Abs(dataPoints.StandardDeviation) && dataPoints.SU < _suThreshold)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        public override bool Identify(SecurityPrice price)
        {
            if (price.Index > MeanValue == false)
            {
                return(false);
            }

            IStatisticsCalculator calc = new StatisticCalculator(MeanValue);
            var calculation            = calc.Calculate(price);

            var currentSU = calculation.SU;

            var currentStdev = calculation.StandardDeviation;
            var currentMean  = calculation.Mean;
            var currentPrice = price.Price;

            CurrentMean  = currentMean;
            CurrentStDev = currentStdev;
            CurrentSU    = currentSU;

            double bottomBand = 0;
            double upperBand  = 0;



            //if (currentSU < 0)
            //{
            bottomBand       = currentMean - Math.Abs(currentStdev);
            CurrentLowerBand = bottomBand;
            //}
            //else if (currentSU > 0)
            //{
            upperBand        = currentMean + Math.Abs(currentStdev);
            CurrentUpperBand = upperBand;
            //}

            if (PriceLocation == PriceLocationOnChart.PriceIsBelowLowerBand)
            {
                if (currentSU >= (LowerStandardUnitLimit) * -1)
                {
                    return(false);
                }
            }

            if (PriceLocation == PriceLocationOnChart.PriceIsAboveUpperBand)
            {
                if (currentSU <= UpperStandardUnitLimit)
                {
                    return(false);
                }
            }



            if (PriceLocation == PriceLocationOnChart.PriceIsBelowLowerBand)
            {
                if (currentPrice < bottomBand)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            if (PriceLocation == PriceLocationOnChart.PriceIsAboveUpperBand)
            {
                if (currentPrice > upperBand)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (PriceLocation == PriceLocationOnChart.PriceIsBetweenLowerAndUpperBands)
            {
                if (currentPrice < upperBand && currentPrice > bottomBand)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }