Esempio n. 1
0
        /// <summary>
        /// Colors the chart background depending on sessions
        /// </summary>
        /// <returns></returns>
        public SessionBackgroundChart SessionBackgroundChart(Data.IDataSeries input, Color asianColor, int asianEndHour, int asianEndMinute, int asianStartHour, int asianStartMinute, Color londonColor, int londonEndHour, int londonEndMinute, int londonStartHour, int londonStartMinute, Color newyorkColor, int newyorkEndHour, int newyorkEndMinute, int newyorkStartHour, int newyorkStartMinute)
        {
            if (cacheSessionBackgroundChart != null)
            {
                for (int idx = 0; idx < cacheSessionBackgroundChart.Length; idx++)
                {
                    if (cacheSessionBackgroundChart[idx].AsianColor == asianColor && cacheSessionBackgroundChart[idx].AsianEndHour == asianEndHour && cacheSessionBackgroundChart[idx].AsianEndMinute == asianEndMinute && cacheSessionBackgroundChart[idx].AsianStartHour == asianStartHour && cacheSessionBackgroundChart[idx].AsianStartMinute == asianStartMinute && cacheSessionBackgroundChart[idx].LondonColor == londonColor && cacheSessionBackgroundChart[idx].LondonEndHour == londonEndHour && cacheSessionBackgroundChart[idx].LondonEndMinute == londonEndMinute && cacheSessionBackgroundChart[idx].LondonStartHour == londonStartHour && cacheSessionBackgroundChart[idx].LondonStartMinute == londonStartMinute && cacheSessionBackgroundChart[idx].NewyorkColor == newyorkColor && cacheSessionBackgroundChart[idx].NewyorkEndHour == newyorkEndHour && cacheSessionBackgroundChart[idx].NewyorkEndMinute == newyorkEndMinute && cacheSessionBackgroundChart[idx].NewyorkStartHour == newyorkStartHour && cacheSessionBackgroundChart[idx].NewyorkStartMinute == newyorkStartMinute && cacheSessionBackgroundChart[idx].EqualsInput(input))
                    {
                        return(cacheSessionBackgroundChart[idx]);
                    }
                }
            }

            lock (checkSessionBackgroundChart)
            {
                checkSessionBackgroundChart.AsianColor = asianColor;
                asianColor = checkSessionBackgroundChart.AsianColor;
                checkSessionBackgroundChart.AsianEndHour = asianEndHour;
                asianEndHour = checkSessionBackgroundChart.AsianEndHour;
                checkSessionBackgroundChart.AsianEndMinute = asianEndMinute;
                asianEndMinute = checkSessionBackgroundChart.AsianEndMinute;
                checkSessionBackgroundChart.AsianStartHour = asianStartHour;
                asianStartHour = checkSessionBackgroundChart.AsianStartHour;
                checkSessionBackgroundChart.AsianStartMinute = asianStartMinute;
                asianStartMinute = checkSessionBackgroundChart.AsianStartMinute;
                checkSessionBackgroundChart.LondonColor = londonColor;
                londonColor = checkSessionBackgroundChart.LondonColor;
                checkSessionBackgroundChart.LondonEndHour = londonEndHour;
                londonEndHour = checkSessionBackgroundChart.LondonEndHour;
                checkSessionBackgroundChart.LondonEndMinute = londonEndMinute;
                londonEndMinute = checkSessionBackgroundChart.LondonEndMinute;
                checkSessionBackgroundChart.LondonStartHour = londonStartHour;
                londonStartHour = checkSessionBackgroundChart.LondonStartHour;
                checkSessionBackgroundChart.LondonStartMinute = londonStartMinute;
                londonStartMinute = checkSessionBackgroundChart.LondonStartMinute;
                checkSessionBackgroundChart.NewyorkColor = newyorkColor;
                newyorkColor = checkSessionBackgroundChart.NewyorkColor;
                checkSessionBackgroundChart.NewyorkEndHour = newyorkEndHour;
                newyorkEndHour = checkSessionBackgroundChart.NewyorkEndHour;
                checkSessionBackgroundChart.NewyorkEndMinute = newyorkEndMinute;
                newyorkEndMinute = checkSessionBackgroundChart.NewyorkEndMinute;
                checkSessionBackgroundChart.NewyorkStartHour = newyorkStartHour;
                newyorkStartHour = checkSessionBackgroundChart.NewyorkStartHour;
                checkSessionBackgroundChart.NewyorkStartMinute = newyorkStartMinute;
                newyorkStartMinute = checkSessionBackgroundChart.NewyorkStartMinute;

                if (cacheSessionBackgroundChart != null)
                {
                    for (int idx = 0; idx < cacheSessionBackgroundChart.Length; idx++)
                    {
                        if (cacheSessionBackgroundChart[idx].AsianColor == asianColor && cacheSessionBackgroundChart[idx].AsianEndHour == asianEndHour && cacheSessionBackgroundChart[idx].AsianEndMinute == asianEndMinute && cacheSessionBackgroundChart[idx].AsianStartHour == asianStartHour && cacheSessionBackgroundChart[idx].AsianStartMinute == asianStartMinute && cacheSessionBackgroundChart[idx].LondonColor == londonColor && cacheSessionBackgroundChart[idx].LondonEndHour == londonEndHour && cacheSessionBackgroundChart[idx].LondonEndMinute == londonEndMinute && cacheSessionBackgroundChart[idx].LondonStartHour == londonStartHour && cacheSessionBackgroundChart[idx].LondonStartMinute == londonStartMinute && cacheSessionBackgroundChart[idx].NewyorkColor == newyorkColor && cacheSessionBackgroundChart[idx].NewyorkEndHour == newyorkEndHour && cacheSessionBackgroundChart[idx].NewyorkEndMinute == newyorkEndMinute && cacheSessionBackgroundChart[idx].NewyorkStartHour == newyorkStartHour && cacheSessionBackgroundChart[idx].NewyorkStartMinute == newyorkStartMinute && cacheSessionBackgroundChart[idx].EqualsInput(input))
                        {
                            return(cacheSessionBackgroundChart[idx]);
                        }
                    }
                }

                SessionBackgroundChart indicator = new SessionBackgroundChart();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input              = input;
                indicator.AsianColor         = asianColor;
                indicator.AsianEndHour       = asianEndHour;
                indicator.AsianEndMinute     = asianEndMinute;
                indicator.AsianStartHour     = asianStartHour;
                indicator.AsianStartMinute   = asianStartMinute;
                indicator.LondonColor        = londonColor;
                indicator.LondonEndHour      = londonEndHour;
                indicator.LondonEndMinute    = londonEndMinute;
                indicator.LondonStartHour    = londonStartHour;
                indicator.LondonStartMinute  = londonStartMinute;
                indicator.NewyorkColor       = newyorkColor;
                indicator.NewyorkEndHour     = newyorkEndHour;
                indicator.NewyorkEndMinute   = newyorkEndMinute;
                indicator.NewyorkStartHour   = newyorkStartHour;
                indicator.NewyorkStartMinute = newyorkStartMinute;
                Indicators.Add(indicator);
                indicator.SetUp();

                SessionBackgroundChart[] tmp = new SessionBackgroundChart[cacheSessionBackgroundChart == null ? 1 : cacheSessionBackgroundChart.Length + 1];
                if (cacheSessionBackgroundChart != null)
                {
                    cacheSessionBackgroundChart.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]         = indicator;
                cacheSessionBackgroundChart = tmp;
                return(indicator);
            }
        }
        /// <summary>
        /// Colors the chart background depending on sessions
        /// </summary>
        /// <returns></returns>
        public SessionBackgroundChart SessionBackgroundChart(Data.IDataSeries input, Color asianColor, int asianEndHour, int asianEndMinute, int asianStartHour, int asianStartMinute, Color londonColor, int londonEndHour, int londonEndMinute, int londonStartHour, int londonStartMinute, Color newyorkColor, int newyorkEndHour, int newyorkEndMinute, int newyorkStartHour, int newyorkStartMinute)
        {
            if (cacheSessionBackgroundChart != null)
                for (int idx = 0; idx < cacheSessionBackgroundChart.Length; idx++)
                    if (cacheSessionBackgroundChart[idx].AsianColor == asianColor && cacheSessionBackgroundChart[idx].AsianEndHour == asianEndHour && cacheSessionBackgroundChart[idx].AsianEndMinute == asianEndMinute && cacheSessionBackgroundChart[idx].AsianStartHour == asianStartHour && cacheSessionBackgroundChart[idx].AsianStartMinute == asianStartMinute && cacheSessionBackgroundChart[idx].LondonColor == londonColor && cacheSessionBackgroundChart[idx].LondonEndHour == londonEndHour && cacheSessionBackgroundChart[idx].LondonEndMinute == londonEndMinute && cacheSessionBackgroundChart[idx].LondonStartHour == londonStartHour && cacheSessionBackgroundChart[idx].LondonStartMinute == londonStartMinute && cacheSessionBackgroundChart[idx].NewyorkColor == newyorkColor && cacheSessionBackgroundChart[idx].NewyorkEndHour == newyorkEndHour && cacheSessionBackgroundChart[idx].NewyorkEndMinute == newyorkEndMinute && cacheSessionBackgroundChart[idx].NewyorkStartHour == newyorkStartHour && cacheSessionBackgroundChart[idx].NewyorkStartMinute == newyorkStartMinute && cacheSessionBackgroundChart[idx].EqualsInput(input))
                        return cacheSessionBackgroundChart[idx];

            lock (checkSessionBackgroundChart)
            {
                checkSessionBackgroundChart.AsianColor = asianColor;
                asianColor = checkSessionBackgroundChart.AsianColor;
                checkSessionBackgroundChart.AsianEndHour = asianEndHour;
                asianEndHour = checkSessionBackgroundChart.AsianEndHour;
                checkSessionBackgroundChart.AsianEndMinute = asianEndMinute;
                asianEndMinute = checkSessionBackgroundChart.AsianEndMinute;
                checkSessionBackgroundChart.AsianStartHour = asianStartHour;
                asianStartHour = checkSessionBackgroundChart.AsianStartHour;
                checkSessionBackgroundChart.AsianStartMinute = asianStartMinute;
                asianStartMinute = checkSessionBackgroundChart.AsianStartMinute;
                checkSessionBackgroundChart.LondonColor = londonColor;
                londonColor = checkSessionBackgroundChart.LondonColor;
                checkSessionBackgroundChart.LondonEndHour = londonEndHour;
                londonEndHour = checkSessionBackgroundChart.LondonEndHour;
                checkSessionBackgroundChart.LondonEndMinute = londonEndMinute;
                londonEndMinute = checkSessionBackgroundChart.LondonEndMinute;
                checkSessionBackgroundChart.LondonStartHour = londonStartHour;
                londonStartHour = checkSessionBackgroundChart.LondonStartHour;
                checkSessionBackgroundChart.LondonStartMinute = londonStartMinute;
                londonStartMinute = checkSessionBackgroundChart.LondonStartMinute;
                checkSessionBackgroundChart.NewyorkColor = newyorkColor;
                newyorkColor = checkSessionBackgroundChart.NewyorkColor;
                checkSessionBackgroundChart.NewyorkEndHour = newyorkEndHour;
                newyorkEndHour = checkSessionBackgroundChart.NewyorkEndHour;
                checkSessionBackgroundChart.NewyorkEndMinute = newyorkEndMinute;
                newyorkEndMinute = checkSessionBackgroundChart.NewyorkEndMinute;
                checkSessionBackgroundChart.NewyorkStartHour = newyorkStartHour;
                newyorkStartHour = checkSessionBackgroundChart.NewyorkStartHour;
                checkSessionBackgroundChart.NewyorkStartMinute = newyorkStartMinute;
                newyorkStartMinute = checkSessionBackgroundChart.NewyorkStartMinute;

                if (cacheSessionBackgroundChart != null)
                    for (int idx = 0; idx < cacheSessionBackgroundChart.Length; idx++)
                        if (cacheSessionBackgroundChart[idx].AsianColor == asianColor && cacheSessionBackgroundChart[idx].AsianEndHour == asianEndHour && cacheSessionBackgroundChart[idx].AsianEndMinute == asianEndMinute && cacheSessionBackgroundChart[idx].AsianStartHour == asianStartHour && cacheSessionBackgroundChart[idx].AsianStartMinute == asianStartMinute && cacheSessionBackgroundChart[idx].LondonColor == londonColor && cacheSessionBackgroundChart[idx].LondonEndHour == londonEndHour && cacheSessionBackgroundChart[idx].LondonEndMinute == londonEndMinute && cacheSessionBackgroundChart[idx].LondonStartHour == londonStartHour && cacheSessionBackgroundChart[idx].LondonStartMinute == londonStartMinute && cacheSessionBackgroundChart[idx].NewyorkColor == newyorkColor && cacheSessionBackgroundChart[idx].NewyorkEndHour == newyorkEndHour && cacheSessionBackgroundChart[idx].NewyorkEndMinute == newyorkEndMinute && cacheSessionBackgroundChart[idx].NewyorkStartHour == newyorkStartHour && cacheSessionBackgroundChart[idx].NewyorkStartMinute == newyorkStartMinute && cacheSessionBackgroundChart[idx].EqualsInput(input))
                            return cacheSessionBackgroundChart[idx];

                SessionBackgroundChart indicator = new SessionBackgroundChart();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.AsianColor = asianColor;
                indicator.AsianEndHour = asianEndHour;
                indicator.AsianEndMinute = asianEndMinute;
                indicator.AsianStartHour = asianStartHour;
                indicator.AsianStartMinute = asianStartMinute;
                indicator.LondonColor = londonColor;
                indicator.LondonEndHour = londonEndHour;
                indicator.LondonEndMinute = londonEndMinute;
                indicator.LondonStartHour = londonStartHour;
                indicator.LondonStartMinute = londonStartMinute;
                indicator.NewyorkColor = newyorkColor;
                indicator.NewyorkEndHour = newyorkEndHour;
                indicator.NewyorkEndMinute = newyorkEndMinute;
                indicator.NewyorkStartHour = newyorkStartHour;
                indicator.NewyorkStartMinute = newyorkStartMinute;
                Indicators.Add(indicator);
                indicator.SetUp();

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