Exemplo n.º 1
0
        /// <summary>
        /// Returns a value of 1 when the current close is less than the prior close after penetrating the highest high of the last n bars.
        /// </summary>
        /// <returns></returns>
        public KeyReversalDown KeyReversalDown(Data.IDataSeries input, int period)
        {
            if (cacheKeyReversalDown != null)
            {
                for (int idx = 0; idx < cacheKeyReversalDown.Length; idx++)
                {
                    if (cacheKeyReversalDown[idx].Period == period && cacheKeyReversalDown[idx].EqualsInput(input))
                    {
                        return(cacheKeyReversalDown[idx]);
                    }
                }
            }

            lock (checkKeyReversalDown)
            {
                checkKeyReversalDown.Period = period;
                period = checkKeyReversalDown.Period;

                if (cacheKeyReversalDown != null)
                {
                    for (int idx = 0; idx < cacheKeyReversalDown.Length; idx++)
                    {
                        if (cacheKeyReversalDown[idx].Period == period && cacheKeyReversalDown[idx].EqualsInput(input))
                        {
                            return(cacheKeyReversalDown[idx]);
                        }
                    }
                }

                KeyReversalDown indicator = new KeyReversalDown();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input  = input;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

                KeyReversalDown[] tmp = new KeyReversalDown[cacheKeyReversalDown == null ? 1 : cacheKeyReversalDown.Length + 1];
                if (cacheKeyReversalDown != null)
                {
                    cacheKeyReversalDown.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]  = indicator;
                cacheKeyReversalDown = tmp;
                return(indicator);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a value of 1 when the current close is less than the prior close after penetrating the highest high of the last n bars.
        /// </summary>
        /// <returns></returns>
        public KeyReversalDown KeyReversalDown(Data.IDataSeries input, int period)
        {
            if (cacheKeyReversalDown != null)
                for (int idx = 0; idx < cacheKeyReversalDown.Length; idx++)
                    if (cacheKeyReversalDown[idx].Period == period && cacheKeyReversalDown[idx].EqualsInput(input))
                        return cacheKeyReversalDown[idx];

            lock (checkKeyReversalDown)
            {
                checkKeyReversalDown.Period = period;
                period = checkKeyReversalDown.Period;

                if (cacheKeyReversalDown != null)
                    for (int idx = 0; idx < cacheKeyReversalDown.Length; idx++)
                        if (cacheKeyReversalDown[idx].Period == period && cacheKeyReversalDown[idx].EqualsInput(input))
                            return cacheKeyReversalDown[idx];

                KeyReversalDown indicator = new KeyReversalDown();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

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