Exemplo n.º 1
0
        /// <summary>
        /// The Williams %R is a momentum indicator that is designed to identify overbought and oversold areas in a nontrending market.
        /// </summary>
        /// <returns></returns>
        public WilliamsR WilliamsR(Data.IDataSeries input, int period)
        {
            if (cacheWilliamsR != null)
            {
                for (int idx = 0; idx < cacheWilliamsR.Length; idx++)
                {
                    if (cacheWilliamsR[idx].Period == period && cacheWilliamsR[idx].EqualsInput(input))
                    {
                        return(cacheWilliamsR[idx]);
                    }
                }
            }

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

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

                WilliamsR indicator = new WilliamsR();
                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();

                WilliamsR[] tmp = new WilliamsR[cacheWilliamsR == null ? 1 : cacheWilliamsR.Length + 1];
                if (cacheWilliamsR != null)
                {
                    cacheWilliamsR.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheWilliamsR      = tmp;
                return(indicator);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// The Williams %R is a momentum indicator that is designed to identify overbought and oversold areas in a nontrending market.
        /// </summary>
        /// <returns></returns>
        public WilliamsR WilliamsR(Data.IDataSeries input, int period)
        {
            if (cacheWilliamsR != null)
                for (int idx = 0; idx < cacheWilliamsR.Length; idx++)
                    if (cacheWilliamsR[idx].Period == period && cacheWilliamsR[idx].EqualsInput(input))
                        return cacheWilliamsR[idx];

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

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

                WilliamsR indicator = new WilliamsR();
                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();

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