Esempio n. 1
0
        /// <summary>
        /// является ли текущая формация нашим паттерном
        /// </summary>
        /// <param name="candles">свечи</param>
        /// <param name="indicators">индикаторы</param>
        /// <param name="numberPattern">индекс по которому мы смотрим паттерн</param>
        public bool ThisIsIt(List <Candle> candles, List <IIndicatorCandle> indicators, int numberPattern)
        {
            if (numberPattern - Length <= 0)
            {
                return(false);
            }

            if (Sequence == null ||
                Sequence.Length == 0)
            {
                return(false);
            }

            PatternCandle researched = new PatternCandle();

            researched.Length = Length;
            researched.Expand = Expand;
            //shadow
            //body
            //shadow+body

            researched.SetFromIndex(candles, null, numberPattern);

            List <Candle> incomPattern = researched.GetInCandle();

            if (TypeWatch == TypeWatchCandlePattern.ShadowAndBody)
            {
                for (int i = 0; i < Sequence.Length; i++) // здесь копать
                {
                    /*if (Sequence[i][0] < researched.Sequence[i][0] || Sequence[i][1] > researched.Sequence[i][0] || // опен
                     *  Sequence[i][2] < researched.Sequence[i][2] || Sequence[i][3] > researched.Sequence[i][2] || // хай
                     *  Sequence[i][4] < researched.Sequence[i][4] || Sequence[i][5] > researched.Sequence[i][4] || // лоу
                     *  Sequence[i][6] < researched.Sequence[i][6] || Sequence[i][7] > researched.Sequence[i][6]    // клос
                     *  )
                     * {
                     *  return false;
                     * }*/
                    if (Sequence[i][0] < incomPattern[i].Open || Sequence[i][1] > incomPattern[i].Open ||
                        // опен
                        Sequence[i][2] < incomPattern[i].High || Sequence[i][3] > incomPattern[i].High ||
                        // хай
                        Sequence[i][4] < incomPattern[i].Low || Sequence[i][5] > incomPattern[i].Low ||
                        // лоу
                        Sequence[i][6] < incomPattern[i].Close || Sequence[i][7] > incomPattern[i].Close // клос
                        )
                    {
                        return(false);
                    }
                }
            }
            else if (TypeWatch == TypeWatchCandlePattern.Body)
            {
                for (int i = 0; i < Sequence.Length; i++) // здесь копать
                {
                    /*if (Sequence[i][0] < researched.Sequence[i][0] || Sequence[i][1] > researched.Sequence[i][0] ||
                     *  // опен
                     *  Sequence[i][6] < researched.Sequence[i][6] || Sequence[i][7] > researched.Sequence[i][6] // клос
                     *  )
                     * {
                     *  return false;
                     * }*/
                    if (Sequence[i][0] < incomPattern[i].Open || Sequence[i][1] > incomPattern[i].Open ||
                        // опен
                        Sequence[i][6] < incomPattern[i].Close || Sequence[i][7] > incomPattern[i].Close // клос
                        )
                    {
                        return(false);
                    }
                }
            }

            else if (TypeWatch == TypeWatchCandlePattern.Shadow)
            {
                for (int i = 0; i < Sequence.Length; i++) // здесь копать
                {
                    /*if (Sequence[i][2] < researched.Sequence[i][2] || Sequence[i][3] > researched.Sequence[i][2] ||
                     *  // хай
                     *  Sequence[i][4] < researched.Sequence[i][4] || Sequence[i][5] > researched.Sequence[i][4] // лоу
                     *  )
                     * {
                     *  return false;
                     * }*/
                    if (Sequence[i][2] < incomPattern[i].High || Sequence[i][3] > incomPattern[i].High ||
                        // хай
                        Sequence[i][4] < incomPattern[i].Low || Sequence[i][5] > incomPattern[i].Low
                        )
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }