Ejemplo n.º 1
0
        /// <summary>
        /// Detects common candlestick patterns and marks them on the chart.
        /// </summary>
        /// <returns></returns>
        public CandleStickPattern CandleStickPattern(Data.IDataSeries input, ChartPattern pattern, int trendStrength)
        {
            if (cacheCandleStickPattern != null)
            {
                for (int idx = 0; idx < cacheCandleStickPattern.Length; idx++)
                {
                    if (cacheCandleStickPattern[idx].Pattern == pattern && cacheCandleStickPattern[idx].TrendStrength == trendStrength && cacheCandleStickPattern[idx].EqualsInput(input))
                    {
                        return(cacheCandleStickPattern[idx]);
                    }
                }
            }

            lock (checkCandleStickPattern)
            {
                checkCandleStickPattern.Pattern = pattern;
                pattern = checkCandleStickPattern.Pattern;
                checkCandleStickPattern.TrendStrength = trendStrength;
                trendStrength = checkCandleStickPattern.TrendStrength;

                if (cacheCandleStickPattern != null)
                {
                    for (int idx = 0; idx < cacheCandleStickPattern.Length; idx++)
                    {
                        if (cacheCandleStickPattern[idx].Pattern == pattern && cacheCandleStickPattern[idx].TrendStrength == trendStrength && cacheCandleStickPattern[idx].EqualsInput(input))
                        {
                            return(cacheCandleStickPattern[idx]);
                        }
                    }
                }

                CandleStickPattern indicator = new CandleStickPattern();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input         = input;
                indicator.Pattern       = pattern;
                indicator.TrendStrength = trendStrength;
                Indicators.Add(indicator);
                indicator.SetUp();

                CandleStickPattern[] tmp = new CandleStickPattern[cacheCandleStickPattern == null ? 1 : cacheCandleStickPattern.Length + 1];
                if (cacheCandleStickPattern != null)
                {
                    cacheCandleStickPattern.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]     = indicator;
                cacheCandleStickPattern = tmp;
                return(indicator);
            }
        }
        /// <summary>
        /// Detects common candlestick patterns and marks them on the chart.
        /// </summary>
        /// <returns></returns>
        public CandleStickPattern CandleStickPattern(Data.IDataSeries input, ChartPattern pattern, int trendStrength)
        {
            if (cacheCandleStickPattern != null)
                for (int idx = 0; idx < cacheCandleStickPattern.Length; idx++)
                    if (cacheCandleStickPattern[idx].Pattern == pattern && cacheCandleStickPattern[idx].TrendStrength == trendStrength && cacheCandleStickPattern[idx].EqualsInput(input))
                        return cacheCandleStickPattern[idx];

            lock (checkCandleStickPattern)
            {
                checkCandleStickPattern.Pattern = pattern;
                pattern = checkCandleStickPattern.Pattern;
                checkCandleStickPattern.TrendStrength = trendStrength;
                trendStrength = checkCandleStickPattern.TrendStrength;

                if (cacheCandleStickPattern != null)
                    for (int idx = 0; idx < cacheCandleStickPattern.Length; idx++)
                        if (cacheCandleStickPattern[idx].Pattern == pattern && cacheCandleStickPattern[idx].TrendStrength == trendStrength && cacheCandleStickPattern[idx].EqualsInput(input))
                            return cacheCandleStickPattern[idx];

                CandleStickPattern indicator = new CandleStickPattern();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Pattern = pattern;
                indicator.TrendStrength = trendStrength;
                Indicators.Add(indicator);
                indicator.SetUp();

                CandleStickPattern[] tmp = new CandleStickPattern[cacheCandleStickPattern == null ? 1 : cacheCandleStickPattern.Length + 1];
                if (cacheCandleStickPattern != null)
                    cacheCandleStickPattern.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheCandleStickPattern = tmp;
                return indicator;
            }
        }