예제 #1
0
        /// <summary>
        /// The anaMACDBBLines (Moving Average Convergence/Divergence) is a trend following momentum indicator that shows the relationship between two moving averages of prices.
        /// </summary>
        /// <returns></returns>
        public anaMACDBBLines anaMACDBBLines(Data.IDataSeries input, int bandPeriod, int fast, int slow, double stdDevNumber)
        {
            if (cacheanaMACDBBLines != null)
            {
                for (int idx = 0; idx < cacheanaMACDBBLines.Length; idx++)
                {
                    if (cacheanaMACDBBLines[idx].BandPeriod == bandPeriod && cacheanaMACDBBLines[idx].Fast == fast && cacheanaMACDBBLines[idx].Slow == slow && Math.Abs(cacheanaMACDBBLines[idx].StdDevNumber - stdDevNumber) <= double.Epsilon && cacheanaMACDBBLines[idx].EqualsInput(input))
                    {
                        return(cacheanaMACDBBLines[idx]);
                    }
                }
            }

            lock (checkanaMACDBBLines)
            {
                checkanaMACDBBLines.BandPeriod = bandPeriod;
                bandPeriod = checkanaMACDBBLines.BandPeriod;
                checkanaMACDBBLines.Fast = fast;
                fast = checkanaMACDBBLines.Fast;
                checkanaMACDBBLines.Slow = slow;
                slow = checkanaMACDBBLines.Slow;
                checkanaMACDBBLines.StdDevNumber = stdDevNumber;
                stdDevNumber = checkanaMACDBBLines.StdDevNumber;

                if (cacheanaMACDBBLines != null)
                {
                    for (int idx = 0; idx < cacheanaMACDBBLines.Length; idx++)
                    {
                        if (cacheanaMACDBBLines[idx].BandPeriod == bandPeriod && cacheanaMACDBBLines[idx].Fast == fast && cacheanaMACDBBLines[idx].Slow == slow && Math.Abs(cacheanaMACDBBLines[idx].StdDevNumber - stdDevNumber) <= double.Epsilon && cacheanaMACDBBLines[idx].EqualsInput(input))
                        {
                            return(cacheanaMACDBBLines[idx]);
                        }
                    }
                }

                anaMACDBBLines indicator = new anaMACDBBLines();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input        = input;
                indicator.BandPeriod   = bandPeriod;
                indicator.Fast         = fast;
                indicator.Slow         = slow;
                indicator.StdDevNumber = stdDevNumber;
                Indicators.Add(indicator);
                indicator.SetUp();

                anaMACDBBLines[] tmp = new anaMACDBBLines[cacheanaMACDBBLines == null ? 1 : cacheanaMACDBBLines.Length + 1];
                if (cacheanaMACDBBLines != null)
                {
                    cacheanaMACDBBLines.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheanaMACDBBLines = tmp;
                return(indicator);
            }
        }
예제 #2
0
        /// <summary>
        /// The anaMACDBBLines (Moving Average Convergence/Divergence) is a trend following momentum indicator that shows the relationship between two moving averages of prices.
        /// </summary>
        /// <returns></returns>
        public anaMACDBBLines anaMACDBBLines(Data.IDataSeries input, int bandPeriod, int fast, int slow, double stdDevNumber)
        {
            if (cacheanaMACDBBLines != null)
                for (int idx = 0; idx < cacheanaMACDBBLines.Length; idx++)
                    if (cacheanaMACDBBLines[idx].BandPeriod == bandPeriod && cacheanaMACDBBLines[idx].Fast == fast && cacheanaMACDBBLines[idx].Slow == slow && Math.Abs(cacheanaMACDBBLines[idx].StdDevNumber - stdDevNumber) <= double.Epsilon && cacheanaMACDBBLines[idx].EqualsInput(input))
                        return cacheanaMACDBBLines[idx];

            lock (checkanaMACDBBLines)
            {
                checkanaMACDBBLines.BandPeriod = bandPeriod;
                bandPeriod = checkanaMACDBBLines.BandPeriod;
                checkanaMACDBBLines.Fast = fast;
                fast = checkanaMACDBBLines.Fast;
                checkanaMACDBBLines.Slow = slow;
                slow = checkanaMACDBBLines.Slow;
                checkanaMACDBBLines.StdDevNumber = stdDevNumber;
                stdDevNumber = checkanaMACDBBLines.StdDevNumber;

                if (cacheanaMACDBBLines != null)
                    for (int idx = 0; idx < cacheanaMACDBBLines.Length; idx++)
                        if (cacheanaMACDBBLines[idx].BandPeriod == bandPeriod && cacheanaMACDBBLines[idx].Fast == fast && cacheanaMACDBBLines[idx].Slow == slow && Math.Abs(cacheanaMACDBBLines[idx].StdDevNumber - stdDevNumber) <= double.Epsilon && cacheanaMACDBBLines[idx].EqualsInput(input))
                            return cacheanaMACDBBLines[idx];

                anaMACDBBLines indicator = new anaMACDBBLines();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.BandPeriod = bandPeriod;
                indicator.Fast = fast;
                indicator.Slow = slow;
                indicator.StdDevNumber = stdDevNumber;
                Indicators.Add(indicator);
                indicator.SetUp();

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