Esempio n. 1
0
        /// <summary>
        /// The ROC (Rate-of-Change) indicator displays the difference between the current price and the price x-time periods ago.
        /// </summary>
        /// <returns></returns>
        public ROC ROC(Data.IDataSeries input, int period)
        {
            if (cacheROC != null)
            {
                for (int idx = 0; idx < cacheROC.Length; idx++)
                {
                    if (cacheROC[idx].Period == period && cacheROC[idx].EqualsInput(input))
                    {
                        return(cacheROC[idx]);
                    }
                }
            }

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

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

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

                ROC[] tmp = new ROC[cacheROC == null ? 1 : cacheROC.Length + 1];
                if (cacheROC != null)
                {
                    cacheROC.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheROC            = tmp;
                return(indicator);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// The ROC (Rate-of-Change) indicator displays the difference between the current price and the price x-time periods ago.
        /// </summary>
        /// <returns></returns>
        public ROC ROC(Data.IDataSeries input, int period)
        {
            if (cacheROC != null)
                for (int idx = 0; idx < cacheROC.Length; idx++)
                    if (cacheROC[idx].Period == period && cacheROC[idx].EqualsInput(input))
                        return cacheROC[idx];

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

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

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

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