Exemplo n.º 1
0
        /// <summary>
        /// Plots a vertical histogram of volume by price.
        /// </summary>
        /// <returns></returns>
        public VolumeProfile VolumeProfile(Data.IDataSeries input, int barSpacing, bool drawLines, int transparency)
        {
            if (cacheVolumeProfile != null)
            {
                for (int idx = 0; idx < cacheVolumeProfile.Length; idx++)
                {
                    if (cacheVolumeProfile[idx].BarSpacing == barSpacing && cacheVolumeProfile[idx].DrawLines == drawLines && cacheVolumeProfile[idx].Transparency == transparency && cacheVolumeProfile[idx].EqualsInput(input))
                    {
                        return(cacheVolumeProfile[idx]);
                    }
                }
            }

            lock (checkVolumeProfile)
            {
                checkVolumeProfile.BarSpacing = barSpacing;
                barSpacing = checkVolumeProfile.BarSpacing;
                checkVolumeProfile.DrawLines = drawLines;
                drawLines = checkVolumeProfile.DrawLines;
                checkVolumeProfile.Transparency = transparency;
                transparency = checkVolumeProfile.Transparency;

                if (cacheVolumeProfile != null)
                {
                    for (int idx = 0; idx < cacheVolumeProfile.Length; idx++)
                    {
                        if (cacheVolumeProfile[idx].BarSpacing == barSpacing && cacheVolumeProfile[idx].DrawLines == drawLines && cacheVolumeProfile[idx].Transparency == transparency && cacheVolumeProfile[idx].EqualsInput(input))
                        {
                            return(cacheVolumeProfile[idx]);
                        }
                    }
                }

                VolumeProfile indicator = new VolumeProfile();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input        = input;
                indicator.BarSpacing   = barSpacing;
                indicator.DrawLines    = drawLines;
                indicator.Transparency = transparency;
                Indicators.Add(indicator);
                indicator.SetUp();

                VolumeProfile[] tmp = new VolumeProfile[cacheVolumeProfile == null ? 1 : cacheVolumeProfile.Length + 1];
                if (cacheVolumeProfile != null)
                {
                    cacheVolumeProfile.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheVolumeProfile  = tmp;
                return(indicator);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Plots a vertical histogram of volume by price.
        /// </summary>
        /// <returns></returns>
        public VolumeProfile VolumeProfile(Data.IDataSeries input, int barSpacing, bool drawLines, int transparency)
        {
            if (cacheVolumeProfile != null)
                for (int idx = 0; idx < cacheVolumeProfile.Length; idx++)
                    if (cacheVolumeProfile[idx].BarSpacing == barSpacing && cacheVolumeProfile[idx].DrawLines == drawLines && cacheVolumeProfile[idx].Transparency == transparency && cacheVolumeProfile[idx].EqualsInput(input))
                        return cacheVolumeProfile[idx];

            lock (checkVolumeProfile)
            {
                checkVolumeProfile.BarSpacing = barSpacing;
                barSpacing = checkVolumeProfile.BarSpacing;
                checkVolumeProfile.DrawLines = drawLines;
                drawLines = checkVolumeProfile.DrawLines;
                checkVolumeProfile.Transparency = transparency;
                transparency = checkVolumeProfile.Transparency;

                if (cacheVolumeProfile != null)
                    for (int idx = 0; idx < cacheVolumeProfile.Length; idx++)
                        if (cacheVolumeProfile[idx].BarSpacing == barSpacing && cacheVolumeProfile[idx].DrawLines == drawLines && cacheVolumeProfile[idx].Transparency == transparency && cacheVolumeProfile[idx].EqualsInput(input))
                            return cacheVolumeProfile[idx];

                VolumeProfile indicator = new VolumeProfile();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.BarSpacing = barSpacing;
                indicator.DrawLines = drawLines;
                indicator.Transparency = transparency;
                Indicators.Add(indicator);
                indicator.SetUp();

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