Пример #1
0
        /// <summary>
        /// Volume Zones plots a horizontal histogram that overlays a price chart. The histogram bars stretch from left to right starting at the left side of the chart. The length of each bar is determined by the cumulative total of all volume bars for the periods during which the price fell within the vertical range of the histogram bar.
        /// </summary>
        /// <returns></returns>
        public VolumeZones VolumeZones(Data.IDataSeries input, Color barColorDown, Color barColorUp, int barCount, int barSpacing, bool drawLines, Color lineColor, int transparency)
        {
            if (cacheVolumeZones != null)
            {
                for (int idx = 0; idx < cacheVolumeZones.Length; idx++)
                {
                    if (cacheVolumeZones[idx].BarColorDown == barColorDown && cacheVolumeZones[idx].BarColorUp == barColorUp && cacheVolumeZones[idx].BarCount == barCount && cacheVolumeZones[idx].BarSpacing == barSpacing && cacheVolumeZones[idx].DrawLines == drawLines && cacheVolumeZones[idx].LineColor == lineColor && cacheVolumeZones[idx].Transparency == transparency && cacheVolumeZones[idx].EqualsInput(input))
                    {
                        return(cacheVolumeZones[idx]);
                    }
                }
            }

            lock (checkVolumeZones)
            {
                checkVolumeZones.BarColorDown = barColorDown;
                barColorDown = checkVolumeZones.BarColorDown;
                checkVolumeZones.BarColorUp = barColorUp;
                barColorUp = checkVolumeZones.BarColorUp;
                checkVolumeZones.BarCount = barCount;
                barCount = checkVolumeZones.BarCount;
                checkVolumeZones.BarSpacing = barSpacing;
                barSpacing = checkVolumeZones.BarSpacing;
                checkVolumeZones.DrawLines = drawLines;
                drawLines = checkVolumeZones.DrawLines;
                checkVolumeZones.LineColor = lineColor;
                lineColor = checkVolumeZones.LineColor;
                checkVolumeZones.Transparency = transparency;
                transparency = checkVolumeZones.Transparency;

                if (cacheVolumeZones != null)
                {
                    for (int idx = 0; idx < cacheVolumeZones.Length; idx++)
                    {
                        if (cacheVolumeZones[idx].BarColorDown == barColorDown && cacheVolumeZones[idx].BarColorUp == barColorUp && cacheVolumeZones[idx].BarCount == barCount && cacheVolumeZones[idx].BarSpacing == barSpacing && cacheVolumeZones[idx].DrawLines == drawLines && cacheVolumeZones[idx].LineColor == lineColor && cacheVolumeZones[idx].Transparency == transparency && cacheVolumeZones[idx].EqualsInput(input))
                        {
                            return(cacheVolumeZones[idx]);
                        }
                    }
                }

                VolumeZones indicator = new VolumeZones();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input        = input;
                indicator.BarColorDown = barColorDown;
                indicator.BarColorUp   = barColorUp;
                indicator.BarCount     = barCount;
                indicator.BarSpacing   = barSpacing;
                indicator.DrawLines    = drawLines;
                indicator.LineColor    = lineColor;
                indicator.Transparency = transparency;
                Indicators.Add(indicator);
                indicator.SetUp();

                VolumeZones[] tmp = new VolumeZones[cacheVolumeZones == null ? 1 : cacheVolumeZones.Length + 1];
                if (cacheVolumeZones != null)
                {
                    cacheVolumeZones.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheVolumeZones    = tmp;
                return(indicator);
            }
        }
Пример #2
0
        /// <summary>
        /// Volume Zones plots a horizontal histogram that overlays a price chart. The histogram bars stretch from left to right starting at the left side of the chart. The length of each bar is determined by the cumulative total of all volume bars for the periods during which the price fell within the vertical range of the histogram bar.
        /// </summary>
        /// <returns></returns>
        public VolumeZones VolumeZones(Data.IDataSeries input, Color barColorDown, Color barColorUp, int barCount, int barSpacing, bool drawLines, Color lineColor, int transparency)
        {
            if (cacheVolumeZones != null)
                for (int idx = 0; idx < cacheVolumeZones.Length; idx++)
                    if (cacheVolumeZones[idx].BarColorDown == barColorDown && cacheVolumeZones[idx].BarColorUp == barColorUp && cacheVolumeZones[idx].BarCount == barCount && cacheVolumeZones[idx].BarSpacing == barSpacing && cacheVolumeZones[idx].DrawLines == drawLines && cacheVolumeZones[idx].LineColor == lineColor && cacheVolumeZones[idx].Transparency == transparency && cacheVolumeZones[idx].EqualsInput(input))
                        return cacheVolumeZones[idx];

            lock (checkVolumeZones)
            {
                checkVolumeZones.BarColorDown = barColorDown;
                barColorDown = checkVolumeZones.BarColorDown;
                checkVolumeZones.BarColorUp = barColorUp;
                barColorUp = checkVolumeZones.BarColorUp;
                checkVolumeZones.BarCount = barCount;
                barCount = checkVolumeZones.BarCount;
                checkVolumeZones.BarSpacing = barSpacing;
                barSpacing = checkVolumeZones.BarSpacing;
                checkVolumeZones.DrawLines = drawLines;
                drawLines = checkVolumeZones.DrawLines;
                checkVolumeZones.LineColor = lineColor;
                lineColor = checkVolumeZones.LineColor;
                checkVolumeZones.Transparency = transparency;
                transparency = checkVolumeZones.Transparency;

                if (cacheVolumeZones != null)
                    for (int idx = 0; idx < cacheVolumeZones.Length; idx++)
                        if (cacheVolumeZones[idx].BarColorDown == barColorDown && cacheVolumeZones[idx].BarColorUp == barColorUp && cacheVolumeZones[idx].BarCount == barCount && cacheVolumeZones[idx].BarSpacing == barSpacing && cacheVolumeZones[idx].DrawLines == drawLines && cacheVolumeZones[idx].LineColor == lineColor && cacheVolumeZones[idx].Transparency == transparency && cacheVolumeZones[idx].EqualsInput(input))
                            return cacheVolumeZones[idx];

                VolumeZones indicator = new VolumeZones();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.BarColorDown = barColorDown;
                indicator.BarColorUp = barColorUp;
                indicator.BarCount = barCount;
                indicator.BarSpacing = barSpacing;
                indicator.DrawLines = drawLines;
                indicator.LineColor = lineColor;
                indicator.Transparency = transparency;
                Indicators.Add(indicator);
                indicator.SetUp();

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