Exemple #1
0
        /// <summary>
        /// OBV (On Balance Volume) is a running total of volume. It shows if volume is flowing into or out of a security. When the security closes higher than the previous close, all of the day's volume is considered up-volume. When the security closes lower than the previous close, all of the day's volume is considered down-volume.
        /// </summary>
        /// <returns></returns>
        public OBV OBV(Data.IDataSeries input)
        {
            if (cacheOBV != null)
            {
                for (int idx = 0; idx < cacheOBV.Length; idx++)
                {
                    if (cacheOBV[idx].EqualsInput(input))
                    {
                        return(cacheOBV[idx]);
                    }
                }
            }

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

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

                OBV[] tmp = new OBV[cacheOBV == null ? 1 : cacheOBV.Length + 1];
                if (cacheOBV != null)
                {
                    cacheOBV.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheOBV            = tmp;
                return(indicator);
            }
        }
Exemple #2
0
        /// <summary>
        /// OBV (On Balance Volume) is a running total of volume. It shows if volume is flowing into or out of a security. When the security closes higher than the previous close, all of the day's volume is considered up-volume. When the security closes lower than the previous close, all of the day's volume is considered down-volume.
        /// </summary>
        /// <returns></returns>
        public OBV OBV(Data.IDataSeries input)
        {
            if (cacheOBV != null)
                for (int idx = 0; idx < cacheOBV.Length; idx++)
                    if (cacheOBV[idx].EqualsInput(input))
                        return cacheOBV[idx];

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

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

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