示例#1
0
        /// <summary>
        /// AB trend 2 indicator
        /// </summary>
        /// <returns></returns>
        public AbTrend2 ABTrend2(Data.IDataSeries input, Color backgroundcolorDn, Color backgroundcolorUp, bool colorAllBackgrounds, bool colorBackground, DashStyle dash1Style, Color downColor, double multiplier, int opacity, bool paintBars, int periodATR, int periodMedian, PlotStyle plot1Style, int plot1Width, bool showArrows, bool showStopLine, Color upColor)
        {
            if (cacheABTrend2 != null)
            {
                for (int idx = 0; idx < cacheABTrend2.Length; idx++)
                {
                    if (cacheABTrend2[idx].BackgroundcolorDn == backgroundcolorDn && cacheABTrend2[idx].BackgroundcolorUp == backgroundcolorUp && cacheABTrend2[idx].ColorAllBackgrounds == colorAllBackgrounds && cacheABTrend2[idx].ColorBackground == colorBackground && cacheABTrend2[idx].Dash1Style == dash1Style && cacheABTrend2[idx].DownColor == downColor && Math.Abs(cacheABTrend2[idx].Multiplier - multiplier) <= double.Epsilon && cacheABTrend2[idx].Opacity == opacity && cacheABTrend2[idx].PaintBars == paintBars && cacheABTrend2[idx].PeriodAtr == periodATR && cacheABTrend2[idx].PeriodMedian == periodMedian && cacheABTrend2[idx].Plot1Style == plot1Style && cacheABTrend2[idx].Plot1Width == plot1Width && cacheABTrend2[idx].ShowArrows == showArrows && cacheABTrend2[idx].ShowStopLine == showStopLine && cacheABTrend2[idx].UpColor == upColor && cacheABTrend2[idx].EqualsInput(input))
                    {
                        return(cacheABTrend2[idx]);
                    }
                }
            }

            lock (checkABTrend2)
            {
                checkABTrend2.BackgroundcolorDn = backgroundcolorDn;
                backgroundcolorDn = checkABTrend2.BackgroundcolorDn;
                checkABTrend2.BackgroundcolorUp = backgroundcolorUp;
                backgroundcolorUp = checkABTrend2.BackgroundcolorUp;
                checkABTrend2.ColorAllBackgrounds = colorAllBackgrounds;
                colorAllBackgrounds           = checkABTrend2.ColorAllBackgrounds;
                checkABTrend2.ColorBackground = colorBackground;
                colorBackground          = checkABTrend2.ColorBackground;
                checkABTrend2.Dash1Style = dash1Style;
                dash1Style = checkABTrend2.Dash1Style;
                checkABTrend2.DownColor = downColor;
                downColor = checkABTrend2.DownColor;
                checkABTrend2.Multiplier = multiplier;
                multiplier            = checkABTrend2.Multiplier;
                checkABTrend2.Opacity = opacity;
                opacity = checkABTrend2.Opacity;
                checkABTrend2.PaintBars = paintBars;
                paintBars = checkABTrend2.PaintBars;
                checkABTrend2.PeriodAtr = periodATR;
                periodATR = checkABTrend2.PeriodAtr;
                checkABTrend2.PeriodMedian = periodMedian;
                periodMedian             = checkABTrend2.PeriodMedian;
                checkABTrend2.Plot1Style = plot1Style;
                plot1Style = checkABTrend2.Plot1Style;
                checkABTrend2.Plot1Width = plot1Width;
                plot1Width = checkABTrend2.Plot1Width;
                checkABTrend2.ShowArrows = showArrows;
                showArrows = checkABTrend2.ShowArrows;
                checkABTrend2.ShowStopLine = showStopLine;
                showStopLine          = checkABTrend2.ShowStopLine;
                checkABTrend2.UpColor = upColor;
                upColor = checkABTrend2.UpColor;

                if (cacheABTrend2 != null)
                {
                    for (int idx = 0; idx < cacheABTrend2.Length; idx++)
                    {
                        if (cacheABTrend2[idx].BackgroundcolorDn == backgroundcolorDn && cacheABTrend2[idx].BackgroundcolorUp == backgroundcolorUp && cacheABTrend2[idx].ColorAllBackgrounds == colorAllBackgrounds && cacheABTrend2[idx].ColorBackground == colorBackground && cacheABTrend2[idx].Dash1Style == dash1Style && cacheABTrend2[idx].DownColor == downColor && Math.Abs(cacheABTrend2[idx].Multiplier - multiplier) <= double.Epsilon && cacheABTrend2[idx].Opacity == opacity && cacheABTrend2[idx].PaintBars == paintBars && cacheABTrend2[idx].PeriodAtr == periodATR && cacheABTrend2[idx].PeriodMedian == periodMedian && cacheABTrend2[idx].Plot1Style == plot1Style && cacheABTrend2[idx].Plot1Width == plot1Width && cacheABTrend2[idx].ShowArrows == showArrows && cacheABTrend2[idx].ShowStopLine == showStopLine && cacheABTrend2[idx].UpColor == upColor && cacheABTrend2[idx].EqualsInput(input))
                        {
                            return(cacheABTrend2[idx]);
                        }
                    }
                }

                AbTrend2 indicator = new AbTrend2();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input               = input;
                indicator.BackgroundcolorDn   = backgroundcolorDn;
                indicator.BackgroundcolorUp   = backgroundcolorUp;
                indicator.ColorAllBackgrounds = colorAllBackgrounds;
                indicator.ColorBackground     = colorBackground;
                indicator.Dash1Style          = dash1Style;
                indicator.DownColor           = downColor;
                indicator.Multiplier          = multiplier;
                indicator.Opacity             = opacity;
                indicator.PaintBars           = paintBars;
                indicator.PeriodAtr           = periodATR;
                indicator.PeriodMedian        = periodMedian;
                indicator.Plot1Style          = plot1Style;
                indicator.Plot1Width          = plot1Width;
                indicator.ShowArrows          = showArrows;
                indicator.ShowStopLine        = showStopLine;
                indicator.UpColor             = upColor;
                Indicators.Add(indicator);
                indicator.SetUp();

                AbTrend2[] tmp = new AbTrend2[cacheABTrend2 == null ? 1 : cacheABTrend2.Length + 1];
                if (cacheABTrend2 != null)
                {
                    cacheABTrend2.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheABTrend2       = tmp;
                return(indicator);
            }
        }
示例#2
0
        /// <summary>
        /// AB trend 2 indicator
        /// </summary>
        /// <returns></returns>
        public AbTrend2 ABTrend2(Data.IDataSeries input, Color backgroundcolorDn, Color backgroundcolorUp, bool colorAllBackgrounds, bool colorBackground, DashStyle dash1Style, Color downColor, double multiplier, int opacity, bool paintBars, int periodATR, int periodMedian, PlotStyle plot1Style, int plot1Width, bool showArrows, bool showStopLine, Color upColor)
        {
            if (cacheABTrend2 != null)
                for (int idx = 0; idx < cacheABTrend2.Length; idx++)
                    if (cacheABTrend2[idx].BackgroundcolorDn == backgroundcolorDn && cacheABTrend2[idx].BackgroundcolorUp == backgroundcolorUp && cacheABTrend2[idx].ColorAllBackgrounds == colorAllBackgrounds && cacheABTrend2[idx].ColorBackground == colorBackground && cacheABTrend2[idx].Dash1Style == dash1Style && cacheABTrend2[idx].DownColor == downColor && Math.Abs(cacheABTrend2[idx].Multiplier - multiplier) <= double.Epsilon && cacheABTrend2[idx].Opacity == opacity && cacheABTrend2[idx].PaintBars == paintBars && cacheABTrend2[idx].PeriodAtr == periodATR && cacheABTrend2[idx].PeriodMedian == periodMedian && cacheABTrend2[idx].Plot1Style == plot1Style && cacheABTrend2[idx].Plot1Width == plot1Width && cacheABTrend2[idx].ShowArrows == showArrows && cacheABTrend2[idx].ShowStopLine == showStopLine && cacheABTrend2[idx].UpColor == upColor && cacheABTrend2[idx].EqualsInput(input))
                        return cacheABTrend2[idx];

            lock (checkABTrend2)
            {
                checkABTrend2.BackgroundcolorDn = backgroundcolorDn;
                backgroundcolorDn = checkABTrend2.BackgroundcolorDn;
                checkABTrend2.BackgroundcolorUp = backgroundcolorUp;
                backgroundcolorUp = checkABTrend2.BackgroundcolorUp;
                checkABTrend2.ColorAllBackgrounds = colorAllBackgrounds;
                colorAllBackgrounds = checkABTrend2.ColorAllBackgrounds;
                checkABTrend2.ColorBackground = colorBackground;
                colorBackground = checkABTrend2.ColorBackground;
                checkABTrend2.Dash1Style = dash1Style;
                dash1Style = checkABTrend2.Dash1Style;
                checkABTrend2.DownColor = downColor;
                downColor = checkABTrend2.DownColor;
                checkABTrend2.Multiplier = multiplier;
                multiplier = checkABTrend2.Multiplier;
                checkABTrend2.Opacity = opacity;
                opacity = checkABTrend2.Opacity;
                checkABTrend2.PaintBars = paintBars;
                paintBars = checkABTrend2.PaintBars;
                checkABTrend2.PeriodAtr = periodATR;
                periodATR = checkABTrend2.PeriodAtr;
                checkABTrend2.PeriodMedian = periodMedian;
                periodMedian = checkABTrend2.PeriodMedian;
                checkABTrend2.Plot1Style = plot1Style;
                plot1Style = checkABTrend2.Plot1Style;
                checkABTrend2.Plot1Width = plot1Width;
                plot1Width = checkABTrend2.Plot1Width;
                checkABTrend2.ShowArrows = showArrows;
                showArrows = checkABTrend2.ShowArrows;
                checkABTrend2.ShowStopLine = showStopLine;
                showStopLine = checkABTrend2.ShowStopLine;
                checkABTrend2.UpColor = upColor;
                upColor = checkABTrend2.UpColor;

                if (cacheABTrend2 != null)
                    for (int idx = 0; idx < cacheABTrend2.Length; idx++)
                        if (cacheABTrend2[idx].BackgroundcolorDn == backgroundcolorDn && cacheABTrend2[idx].BackgroundcolorUp == backgroundcolorUp && cacheABTrend2[idx].ColorAllBackgrounds == colorAllBackgrounds && cacheABTrend2[idx].ColorBackground == colorBackground && cacheABTrend2[idx].Dash1Style == dash1Style && cacheABTrend2[idx].DownColor == downColor && Math.Abs(cacheABTrend2[idx].Multiplier - multiplier) <= double.Epsilon && cacheABTrend2[idx].Opacity == opacity && cacheABTrend2[idx].PaintBars == paintBars && cacheABTrend2[idx].PeriodAtr == periodATR && cacheABTrend2[idx].PeriodMedian == periodMedian && cacheABTrend2[idx].Plot1Style == plot1Style && cacheABTrend2[idx].Plot1Width == plot1Width && cacheABTrend2[idx].ShowArrows == showArrows && cacheABTrend2[idx].ShowStopLine == showStopLine && cacheABTrend2[idx].UpColor == upColor && cacheABTrend2[idx].EqualsInput(input))
                            return cacheABTrend2[idx];

                AbTrend2 indicator = new AbTrend2();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.BackgroundcolorDn = backgroundcolorDn;
                indicator.BackgroundcolorUp = backgroundcolorUp;
                indicator.ColorAllBackgrounds = colorAllBackgrounds;
                indicator.ColorBackground = colorBackground;
                indicator.Dash1Style = dash1Style;
                indicator.DownColor = downColor;
                indicator.Multiplier = multiplier;
                indicator.Opacity = opacity;
                indicator.PaintBars = paintBars;
                indicator.PeriodAtr = periodATR;
                indicator.PeriodMedian = periodMedian;
                indicator.Plot1Style = plot1Style;
                indicator.Plot1Width = plot1Width;
                indicator.ShowArrows = showArrows;
                indicator.ShowStopLine = showStopLine;
                indicator.UpColor = upColor;
                Indicators.Add(indicator);
                indicator.SetUp();

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