示例#1
0
        /// <summary>
        /// The Hull Moving Average (HMA) employs weighted MA calculations to offer superior smoothing, and much less lag, over traditional SMA indicators.
        /// </summary>
        /// <returns></returns>
        public HMA HMA(Data.IDataSeries input, int period)
        {
            if (cacheHMA != null)
            {
                for (int idx = 0; idx < cacheHMA.Length; idx++)
                {
                    if (cacheHMA[idx].Period == period && cacheHMA[idx].EqualsInput(input))
                    {
                        return(cacheHMA[idx]);
                    }
                }
            }

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

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

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

                HMA[] tmp = new HMA[cacheHMA == null ? 1 : cacheHMA.Length + 1];
                if (cacheHMA != null)
                {
                    cacheHMA.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheHMA            = tmp;
                return(indicator);
            }
        }
示例#2
0
        /// <summary>
        /// The Hull Moving Average (HMA) employs weighted MA calculations to offer superior smoothing, and much less lag, over traditional SMA indicators.
        /// </summary>
        /// <returns></returns>
        public HMA HMA(Data.IDataSeries input, int period)
        {
            if (cacheHMA != null)
                for (int idx = 0; idx < cacheHMA.Length; idx++)
                    if (cacheHMA[idx].Period == period && cacheHMA[idx].EqualsInput(input))
                        return cacheHMA[idx];

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

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

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

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