Exemple #1
0
        /**
         * @param index the current bar/candle index
         * @return true if the current bar/candle is a white soldier, false otherwise
         */
        private bool isWhiteSoldier(int index)
        {
            IBar prevBar = _series.GetBar(index - 1);
            IBar currBar = _series.GetBar(index);

            if (currBar.IsBullish())
            {
                if (prevBar.IsBearish())
                {
                    // First soldier case
                    return(hasVeryShortUpperShadow(index) &&
                           currBar.OpenPrice.IsGreaterThan(prevBar.MinPrice));
                }
                else
                {
                    return(hasVeryShortUpperShadow(index) && isGrowing(index));
                }
            }
            return(false);
        }
Exemple #2
0
        /**
         * @param index the current bar/candle index
         * @return true if the current bar/candle is a black crow, false otherwise
         */
        private bool isBlackCrow(int index)
        {
            IBar prevBar = _series.GetBar(index - 1);
            IBar currBar = _series.GetBar(index);

            if (currBar.IsBearish())
            {
                if (prevBar.IsBullish())
                {
                    // First crow case
                    return(hasVeryShortLowerShadow(index) &&
                           currBar.OpenPrice.IsLessThan(prevBar.MaxPrice));
                }
                else
                {
                    return(hasVeryShortLowerShadow(index) && isDeclining(index));
                }
            }
            return(false);
        }
        protected override bool Calculate(int index)
        {
            if (index < 1)
            {
                // Harami is a 2-candle pattern
                return(false);
            }
            IBar prevBar = _series.GetBar(index - 1);
            IBar currBar = _series.GetBar(index);

            if (prevBar.IsBearish() && currBar.IsBullish())
            {
                decimal prevOpenPrice  = prevBar.OpenPrice;
                decimal prevClosePrice = prevBar.ClosePrice;
                decimal currOpenPrice  = currBar.OpenPrice;
                decimal currClosePrice = currBar.ClosePrice;
                return(currOpenPrice.IsLessThan(prevOpenPrice) && currOpenPrice.IsGreaterThan(prevClosePrice) &&
                       currClosePrice.IsLessThan(prevOpenPrice) && currClosePrice.IsGreaterThan(prevClosePrice));
            }
            return(false);
        }