Ejemplo n.º 1
0
        /// <summary>
        /// The WMA (Weighted Moving Average) is a Moving Average indicator that shows the average value of a security's price over a period of time with special emphasis on the more recent portions of the time period under analysis as opposed to the earlier.
        /// </summary>
        /// <returns></returns>
        public WMA WMA(Data.IDataSeries input, int period)
        {
            if (cacheWMA != null)
            {
                for (int idx = 0; idx < cacheWMA.Length; idx++)
                {
                    if (cacheWMA[idx].Period == period && cacheWMA[idx].EqualsInput(input))
                    {
                        return(cacheWMA[idx]);
                    }
                }
            }

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

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

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

                WMA[] tmp = new WMA[cacheWMA == null ? 1 : cacheWMA.Length + 1];
                if (cacheWMA != null)
                {
                    cacheWMA.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheWMA            = tmp;
                return(indicator);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The WMA (Weighted Moving Average) is a Moving Average indicator that shows the average value of a security's price over a period of time with special emphasis on the more recent portions of the time period under analysis as opposed to the earlier.
        /// </summary>
        /// <returns></returns>
        public WMA WMA(Data.IDataSeries input, int period)
        {
            if (cacheWMA != null)
                for (int idx = 0; idx < cacheWMA.Length; idx++)
                    if (cacheWMA[idx].Period == period && cacheWMA[idx].EqualsInput(input))
                        return cacheWMA[idx];

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

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

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

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