Ejemplo n.º 1
0
        /// <summary>
        /// Calculates the Hurst Exponent (H) of a time series.  Interpretation is H < 0.5 => mean reverting, H == 0.5 => random, H > 0.5 => trending.
        /// </summary>
        /// <returns></returns>
        public jhlHurstExponent jhlHurstExponent(Data.IDataSeries input, int periods)
        {
            if (cachejhlHurstExponent != null)
            {
                for (int idx = 0; idx < cachejhlHurstExponent.Length; idx++)
                {
                    if (cachejhlHurstExponent[idx].Periods == periods && cachejhlHurstExponent[idx].EqualsInput(input))
                    {
                        return(cachejhlHurstExponent[idx]);
                    }
                }
            }

            lock (checkjhlHurstExponent)
            {
                checkjhlHurstExponent.Periods = periods;
                periods = checkjhlHurstExponent.Periods;

                if (cachejhlHurstExponent != null)
                {
                    for (int idx = 0; idx < cachejhlHurstExponent.Length; idx++)
                    {
                        if (cachejhlHurstExponent[idx].Periods == periods && cachejhlHurstExponent[idx].EqualsInput(input))
                        {
                            return(cachejhlHurstExponent[idx]);
                        }
                    }
                }

                jhlHurstExponent indicator = new jhlHurstExponent();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input   = input;
                indicator.Periods = periods;
                Indicators.Add(indicator);
                indicator.SetUp();

                jhlHurstExponent[] tmp = new jhlHurstExponent[cachejhlHurstExponent == null ? 1 : cachejhlHurstExponent.Length + 1];
                if (cachejhlHurstExponent != null)
                {
                    cachejhlHurstExponent.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]   = indicator;
                cachejhlHurstExponent = tmp;
                return(indicator);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Calculates the Hurst Exponent (H) of a time series.  Interpretation is H < 0.5 => mean reverting, H == 0.5 => random, H > 0.5 => trending.
        /// </summary>
        /// <returns></returns>
        public jhlHurstExponent jhlHurstExponent(Data.IDataSeries input, int periods)
        {
            if (cachejhlHurstExponent != null)
                for (int idx = 0; idx < cachejhlHurstExponent.Length; idx++)
                    if (cachejhlHurstExponent[idx].Periods == periods && cachejhlHurstExponent[idx].EqualsInput(input))
                        return cachejhlHurstExponent[idx];

            lock (checkjhlHurstExponent)
            {
                checkjhlHurstExponent.Periods = periods;
                periods = checkjhlHurstExponent.Periods;

                if (cachejhlHurstExponent != null)
                    for (int idx = 0; idx < cachejhlHurstExponent.Length; idx++)
                        if (cachejhlHurstExponent[idx].Periods == periods && cachejhlHurstExponent[idx].EqualsInput(input))
                            return cachejhlHurstExponent[idx];

                jhlHurstExponent indicator = new jhlHurstExponent();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Periods = periods;
                Indicators.Add(indicator);
                indicator.SetUp();

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