示例#1
0
        /// <summary>
        /// The TSF (Time Series Forecast) calculates probable future values for the price by fitting a linear regression line over a given number of price bars and following that line forward into the future. A linear regression line is a straight line which is as close to all of the given price points as possible. Also see the Linear Regression indicator.
        /// </summary>
        /// <returns></returns>
        public TSF TSF(Data.IDataSeries input, int forecast, int period)
        {
            if (cacheTSF != null)
            {
                for (int idx = 0; idx < cacheTSF.Length; idx++)
                {
                    if (cacheTSF[idx].Forecast == forecast && cacheTSF[idx].Period == period && cacheTSF[idx].EqualsInput(input))
                    {
                        return(cacheTSF[idx]);
                    }
                }
            }

            lock (checkTSF)
            {
                checkTSF.Forecast = forecast;
                forecast          = checkTSF.Forecast;
                checkTSF.Period   = period;
                period            = checkTSF.Period;

                if (cacheTSF != null)
                {
                    for (int idx = 0; idx < cacheTSF.Length; idx++)
                    {
                        if (cacheTSF[idx].Forecast == forecast && cacheTSF[idx].Period == period && cacheTSF[idx].EqualsInput(input))
                        {
                            return(cacheTSF[idx]);
                        }
                    }
                }

                TSF indicator = new TSF();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input    = input;
                indicator.Forecast = forecast;
                indicator.Period   = period;
                Indicators.Add(indicator);
                indicator.SetUp();

                TSF[] tmp = new TSF[cacheTSF == null ? 1 : cacheTSF.Length + 1];
                if (cacheTSF != null)
                {
                    cacheTSF.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheTSF            = tmp;
                return(indicator);
            }
        }
示例#2
0
        /// <summary>
        /// The TSF (Time Series Forecast) calculates probable future values for the price by fitting a linear regression line over a given number of price bars and following that line forward into the future. A linear regression line is a straight line which is as close to all of the given price points as possible. Also see the Linear Regression indicator.
        /// </summary>
        /// <returns></returns>
        public TSF TSF(Data.IDataSeries input, int forecast, int period)
        {
            if (cacheTSF != null)
                for (int idx = 0; idx < cacheTSF.Length; idx++)
                    if (cacheTSF[idx].Forecast == forecast && cacheTSF[idx].Period == period && cacheTSF[idx].EqualsInput(input))
                        return cacheTSF[idx];

            lock (checkTSF)
            {
                checkTSF.Forecast = forecast;
                forecast = checkTSF.Forecast;
                checkTSF.Period = period;
                period = checkTSF.Period;

                if (cacheTSF != null)
                    for (int idx = 0; idx < cacheTSF.Length; idx++)
                        if (cacheTSF[idx].Forecast == forecast && cacheTSF[idx].Period == period && cacheTSF[idx].EqualsInput(input))
                            return cacheTSF[idx];

                TSF indicator = new TSF();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Forecast = forecast;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

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