Пример #1
0
        /// <summary>
        /// The RVI (Relative Volatility Index) was developed by Donald Dorsey as a compliment to and a confirmation of momentum based indicators. When used to confirm other signals, only buy when the RVI is over 50 and only sell when the RVI is under 50.
        /// </summary>
        /// <returns></returns>
        public RVI RVI(Data.IDataSeries input, int period)
        {
            if (cacheRVI != null)
            {
                for (int idx = 0; idx < cacheRVI.Length; idx++)
                {
                    if (cacheRVI[idx].Period == period && cacheRVI[idx].EqualsInput(input))
                    {
                        return(cacheRVI[idx]);
                    }
                }
            }

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

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

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

                RVI[] tmp = new RVI[cacheRVI == null ? 1 : cacheRVI.Length + 1];
                if (cacheRVI != null)
                {
                    cacheRVI.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheRVI            = tmp;
                return(indicator);
            }
        }
Пример #2
0
        /// <summary>
        /// The RVI (Relative Volatility Index) was developed by Donald Dorsey as a compliment to and a confirmation of momentum based indicators. When used to confirm other signals, only buy when the RVI is over 50 and only sell when the RVI is under 50.
        /// </summary>
        /// <returns></returns>
        public RVI RVI(Data.IDataSeries input, int period)
        {
            if (cacheRVI != null)
                for (int idx = 0; idx < cacheRVI.Length; idx++)
                    if (cacheRVI[idx].Period == period && cacheRVI[idx].EqualsInput(input))
                        return cacheRVI[idx];

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

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

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

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