Esempio n. 1
0
        /// <summary>
        /// This is a sample for an indicator using custom plotting.
        /// </summary>
        /// <returns></returns>
        public CustomPlotSample CustomPlotSample(Data.IDataSeries input)
        {
            if (cacheCustomPlotSample != null)
            {
                for (int idx = 0; idx < cacheCustomPlotSample.Length; idx++)
                {
                    if (cacheCustomPlotSample[idx].EqualsInput(input))
                    {
                        return(cacheCustomPlotSample[idx]);
                    }
                }
            }

            lock (checkCustomPlotSample)
            {
                if (cacheCustomPlotSample != null)
                {
                    for (int idx = 0; idx < cacheCustomPlotSample.Length; idx++)
                    {
                        if (cacheCustomPlotSample[idx].EqualsInput(input))
                        {
                            return(cacheCustomPlotSample[idx]);
                        }
                    }
                }

                CustomPlotSample indicator = new CustomPlotSample();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                Indicators.Add(indicator);
                indicator.SetUp();

                CustomPlotSample[] tmp = new CustomPlotSample[cacheCustomPlotSample == null ? 1 : cacheCustomPlotSample.Length + 1];
                if (cacheCustomPlotSample != null)
                {
                    cacheCustomPlotSample.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]   = indicator;
                cacheCustomPlotSample = tmp;
                return(indicator);
            }
        }
        /// <summary>
        /// This is a sample for an indicator using custom plotting.
        /// </summary>
        /// <returns></returns>
        public CustomPlotSample CustomPlotSample(Data.IDataSeries input)
        {
            if (cacheCustomPlotSample != null)
                for (int idx = 0; idx < cacheCustomPlotSample.Length; idx++)
                    if (cacheCustomPlotSample[idx].EqualsInput(input))
                        return cacheCustomPlotSample[idx];

            lock (checkCustomPlotSample)
            {
                if (cacheCustomPlotSample != null)
                    for (int idx = 0; idx < cacheCustomPlotSample.Length; idx++)
                        if (cacheCustomPlotSample[idx].EqualsInput(input))
                            return cacheCustomPlotSample[idx];

                CustomPlotSample indicator = new CustomPlotSample();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                Indicators.Add(indicator);
                indicator.SetUp();

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