public virtual bool TurnOver(DataRowCollection rows, int index)
        {
            if (!AnalysisCommon.CheckTrendPeriod(index, rows.Count, TrendPeriod))
            {
                return(false);
            }

            AnalysisCommon.TrendDirection before = AnalysisCommon.TrendDirection.None;
            AnalysisCommon.TrendDirection after  = AnalysisCommon.TrendDirection.None;

            try
            {
                before = AnalysisCommon.CheckBeforeTrendDirection(rows, index, TrendPeriod);
                after  = AnalysisCommon.CheckAfterTrendDirection(rows, index, TrendPeriod);
            }
            catch (Exception ex)
            {
                if (ex is SMANULLException)
                {
                    return(false);
                }
            }

            if ((before == AnalysisCommon.TrendDirection.Down && after == AnalysisCommon.TrendDirection.Up) ||
                (before == AnalysisCommon.TrendDirection.Up && after == AnalysisCommon.TrendDirection.Down))
            {
                return(true);
            }

            return(false);
        }
        public virtual bool BeforeHasTrend(DataRowCollection rows, int index)
        {
            if (!AnalysisCommon.CheckTrendPeriod(index, rows.Count, TrendPeriod))
            {
                return(false);
            }

            var trendDirect = AnalysisCommon.CheckBeforeTrendDirection(rows, index, TrendPeriod);

            if (trendDirect == AnalysisCommon.TrendDirection.None)
            {
                return(false);
            }

            return(true);
        }
示例#3
0
        public override bool Qualified(DataRowCollection rows, int index, StockData currentPrice, StockData beforePrice, StockData afterPrice)
        {
            if (currentPrice == null || beforePrice == null)
            {
                return(false);
            }

            if (!BeforeHasTrend(rows, index))
            {
                return(false);
            }

            //Before trend must be Down
            if (AnalysisCommon.CheckBeforeTrendDirection(rows, index, _trendPeriod) != AnalysisCommon.TrendDirection.Down)
            {
                return(false);
            }

            //Previous day must be down
            if (beforePrice.open < beforePrice.close)
            {
                return(false);
            }
            //Current day must be up
            if (currentPrice.open > currentPrice.close)
            {
                return(false);
            }

            //Current Open must be less than previous close
            if (currentPrice.open > beforePrice.close)
            {
                return(false);
            }

            //Current close must be greater than previous close
            if (currentPrice.close < beforePrice.close)
            {
                return(false);
            }

            //Shadow line must be very short for previous
            if ((beforePrice.high - beforePrice.close) > (beforePrice.high - beforePrice.low) * multiplier)
            {
                return(false);
            }

            if ((beforePrice.open - beforePrice.low) > (beforePrice.high - beforePrice.low) * multiplier)
            {
                return(false);
            }

            //Shadow line must be very short for current
            if ((currentPrice.high - currentPrice.open) > (currentPrice.high - currentPrice.low) * multiplier)
            {
                return(false);
            }

            if ((currentPrice.close - currentPrice.low) > (currentPrice.high - currentPrice.low) * multiplier)
            {
                return(false);
            }

            //current close must be in body of previous bar for more than 60%
            if ((currentPrice.close - beforePrice.close) < (beforePrice.open - beforePrice.close) * multiplier2)
            {
                return(false);
            }

            return(true);
        }