Ejemplo n.º 1
0
        /// <summary>
        /// The VOLMA (Volume Moving Average) plots an exponential moving average (EMA) of volume.
        /// </summary>
        /// <returns></returns>
        public VOLMA VOLMA(Data.IDataSeries input, int period)
        {
            if (cacheVOLMA != null)
            {
                for (int idx = 0; idx < cacheVOLMA.Length; idx++)
                {
                    if (cacheVOLMA[idx].Period == period && cacheVOLMA[idx].EqualsInput(input))
                    {
                        return(cacheVOLMA[idx]);
                    }
                }
            }

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

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

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

                VOLMA[] tmp = new VOLMA[cacheVOLMA == null ? 1 : cacheVOLMA.Length + 1];
                if (cacheVOLMA != null)
                {
                    cacheVOLMA.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheVOLMA          = tmp;
                return(indicator);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The VOLMA (Volume Moving Average) plots an exponential moving average (EMA) of volume.
        /// </summary>
        /// <returns></returns>
        public VOLMA VOLMA(Data.IDataSeries input, int period)
        {
            if (cacheVOLMA != null)
                for (int idx = 0; idx < cacheVOLMA.Length; idx++)
                    if (cacheVOLMA[idx].Period == period && cacheVOLMA[idx].EqualsInput(input))
                        return cacheVOLMA[idx];

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

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

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

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