Example #1
0
        /// <summary>
        /// Calculates the fractal dimension of an n period time series
        /// </summary>
        /// <returns></returns>
        public jhlFractalDimension jhlFractalDimension(Data.IDataSeries input, int period)
        {
            if (cachejhlFractalDimension != null)
            {
                for (int idx = 0; idx < cachejhlFractalDimension.Length; idx++)
                {
                    if (cachejhlFractalDimension[idx].Period == period && cachejhlFractalDimension[idx].EqualsInput(input))
                    {
                        return(cachejhlFractalDimension[idx]);
                    }
                }
            }

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

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

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

                jhlFractalDimension[] tmp = new jhlFractalDimension[cachejhlFractalDimension == null ? 1 : cachejhlFractalDimension.Length + 1];
                if (cachejhlFractalDimension != null)
                {
                    cachejhlFractalDimension.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]      = indicator;
                cachejhlFractalDimension = tmp;
                return(indicator);
            }
        }
        /// <summary>
        /// Calculates the fractal dimension of an n period time series
        /// </summary>
        /// <returns></returns>
        public jhlFractalDimension jhlFractalDimension(Data.IDataSeries input, int period)
        {
            if (cachejhlFractalDimension != null)
                for (int idx = 0; idx < cachejhlFractalDimension.Length; idx++)
                    if (cachejhlFractalDimension[idx].Period == period && cachejhlFractalDimension[idx].EqualsInput(input))
                        return cachejhlFractalDimension[idx];

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

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

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

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