Пример #1
0
        /// <summary>
        /// Color the chart background for up to three custom time frames.
        /// </summary>
        /// <returns></returns>
        public TimeZoneColors TimeZoneColors(Data.IDataSeries input, bool alertBool, bool colorAll)
        {
            if (cacheTimeZoneColors != null)
            {
                for (int idx = 0; idx < cacheTimeZoneColors.Length; idx++)
                {
                    if (cacheTimeZoneColors[idx].AlertBool == alertBool && cacheTimeZoneColors[idx].ColorAll == colorAll && cacheTimeZoneColors[idx].EqualsInput(input))
                    {
                        return(cacheTimeZoneColors[idx]);
                    }
                }
            }

            lock (checkTimeZoneColors)
            {
                checkTimeZoneColors.AlertBool = alertBool;
                alertBool = checkTimeZoneColors.AlertBool;
                checkTimeZoneColors.ColorAll = colorAll;
                colorAll = checkTimeZoneColors.ColorAll;

                if (cacheTimeZoneColors != null)
                {
                    for (int idx = 0; idx < cacheTimeZoneColors.Length; idx++)
                    {
                        if (cacheTimeZoneColors[idx].AlertBool == alertBool && cacheTimeZoneColors[idx].ColorAll == colorAll && cacheTimeZoneColors[idx].EqualsInput(input))
                        {
                            return(cacheTimeZoneColors[idx]);
                        }
                    }
                }

                TimeZoneColors indicator = new TimeZoneColors();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input     = input;
                indicator.AlertBool = alertBool;
                indicator.ColorAll  = colorAll;
                Indicators.Add(indicator);
                indicator.SetUp();

                TimeZoneColors[] tmp = new TimeZoneColors[cacheTimeZoneColors == null ? 1 : cacheTimeZoneColors.Length + 1];
                if (cacheTimeZoneColors != null)
                {
                    cacheTimeZoneColors.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheTimeZoneColors = tmp;
                return(indicator);
            }
        }
Пример #2
0
        /// <summary>
        /// Color the chart background for up to three custom time frames.
        /// </summary>
        /// <returns></returns>
        public TimeZoneColors TimeZoneColors(Data.IDataSeries input, bool alertBool, bool colorAll)
        {
            if (cacheTimeZoneColors != null)
                for (int idx = 0; idx < cacheTimeZoneColors.Length; idx++)
                    if (cacheTimeZoneColors[idx].AlertBool == alertBool && cacheTimeZoneColors[idx].ColorAll == colorAll && cacheTimeZoneColors[idx].EqualsInput(input))
                        return cacheTimeZoneColors[idx];

            lock (checkTimeZoneColors)
            {
                checkTimeZoneColors.AlertBool = alertBool;
                alertBool = checkTimeZoneColors.AlertBool;
                checkTimeZoneColors.ColorAll = colorAll;
                colorAll = checkTimeZoneColors.ColorAll;

                if (cacheTimeZoneColors != null)
                    for (int idx = 0; idx < cacheTimeZoneColors.Length; idx++)
                        if (cacheTimeZoneColors[idx].AlertBool == alertBool && cacheTimeZoneColors[idx].ColorAll == colorAll && cacheTimeZoneColors[idx].EqualsInput(input))
                            return cacheTimeZoneColors[idx];

                TimeZoneColors indicator = new TimeZoneColors();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.AlertBool = alertBool;
                indicator.ColorAll = colorAll;
                Indicators.Add(indicator);
                indicator.SetUp();

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