Beispiel #1
0
        /// <summary>
        /// The Darvas Boxes were taken from the pages of Nicolas Darvas book, How I Made $2,000,000 in the Stock Market. The boxes are used to normalize a trend. A 'buy' signal would be indicated when the price of the stock exceeds the top of the box. A 'sell' signal would be indicated when the price of the stock falls below the bottom of the box.
        /// </summary>
        /// <returns></returns>
        public Darvas Darvas(Data.IDataSeries input)
        {
            if (cacheDarvas != null)
            {
                for (int idx = 0; idx < cacheDarvas.Length; idx++)
                {
                    if (cacheDarvas[idx].EqualsInput(input))
                    {
                        return(cacheDarvas[idx]);
                    }
                }
            }

            lock (checkDarvas)
            {
                if (cacheDarvas != null)
                {
                    for (int idx = 0; idx < cacheDarvas.Length; idx++)
                    {
                        if (cacheDarvas[idx].EqualsInput(input))
                        {
                            return(cacheDarvas[idx]);
                        }
                    }
                }

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

                Darvas[] tmp = new Darvas[cacheDarvas == null ? 1 : cacheDarvas.Length + 1];
                if (cacheDarvas != null)
                {
                    cacheDarvas.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheDarvas         = tmp;
                return(indicator);
            }
        }
Beispiel #2
0
        /// <summary>
        /// The Darvas Boxes were taken from the pages of Nicolas Darvas book, How I Made $2,000,000 in the Stock Market. The boxes are used to normalize a trend. A 'buy' signal would be indicated when the price of the stock exceeds the top of the box. A 'sell' signal would be indicated when the price of the stock falls below the bottom of the box.
        /// </summary>
        /// <returns></returns>
        public Darvas Darvas(Data.IDataSeries input)
        {
            if (cacheDarvas != null)
                for (int idx = 0; idx < cacheDarvas.Length; idx++)
                    if (cacheDarvas[idx].EqualsInput(input))
                        return cacheDarvas[idx];

            lock (checkDarvas)
            {
                if (cacheDarvas != null)
                    for (int idx = 0; idx < cacheDarvas.Length; idx++)
                        if (cacheDarvas[idx].EqualsInput(input))
                            return cacheDarvas[idx];

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

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