Beispiel #1
0
        /// <summary>
        /// The Forecast Oscillator (FOSC) is an extension of the linear regression based indicators made popular by Tushar Chande. The Forecast Oscillator plots the percentage difference between the forecast price (generated by an x-period linear regression line) and the actual price. The oscillator is above zero when the forecast price is greater than the actual price.  Conversely, it's less than zero if its below. In the rare case when the forecast price and the actual price are the same, the oscillator would plot zero. Actual prices that are persistently below the forecast price suggest lower prices ahead.  Likewise, actual prices that are persistently above the forecast price suggest higher prices ahead. Short-term traders should use shorter time periods and perhaps more relaxed standards for the required length of time above or below the forecast price. Long-term traders should use longer time periods and perhaps stricter standards for the required length of time above or below the forecast price. Chande also suggests plotting a three-day moving average trigger line of the Forecast Oscillator to generate early warnings of changes in trend. When the oscillator crosses below the trigger line, lower prices are suggested. When the oscillator crosses above the trigger line, higher prices are suggested.
        /// </summary>
        /// <returns></returns>
        public FOSC FOSC(Data.IDataSeries input, int period)
        {
            if (cacheFOSC != null)
            {
                for (int idx = 0; idx < cacheFOSC.Length; idx++)
                {
                    if (cacheFOSC[idx].Period == period && cacheFOSC[idx].EqualsInput(input))
                    {
                        return(cacheFOSC[idx]);
                    }
                }
            }

            lock (checkFOSC)
            {
                checkFOSC.Period = period;
                period           = checkFOSC.Period;

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

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

                FOSC[] tmp = new FOSC[cacheFOSC == null ? 1 : cacheFOSC.Length + 1];
                if (cacheFOSC != null)
                {
                    cacheFOSC.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheFOSC           = tmp;
                return(indicator);
            }
        }
Beispiel #2
0
        /// <summary>
        /// The Forecast Oscillator (FOSC) is an extension of the linear regression based indicators made popular by Tushar Chande. The Forecast Oscillator plots the percentage difference between the forecast price (generated by an x-period linear regression line) and the actual price. The oscillator is above zero when the forecast price is greater than the actual price.  Conversely, it's less than zero if its below. In the rare case when the forecast price and the actual price are the same, the oscillator would plot zero. Actual prices that are persistently below the forecast price suggest lower prices ahead.  Likewise, actual prices that are persistently above the forecast price suggest higher prices ahead. Short-term traders should use shorter time periods and perhaps more relaxed standards for the required length of time above or below the forecast price. Long-term traders should use longer time periods and perhaps stricter standards for the required length of time above or below the forecast price. Chande also suggests plotting a three-day moving average trigger line of the Forecast Oscillator to generate early warnings of changes in trend. When the oscillator crosses below the trigger line, lower prices are suggested. When the oscillator crosses above the trigger line, higher prices are suggested.
        /// </summary>
        /// <returns></returns>
        public FOSC FOSC(Data.IDataSeries input, int period)
        {
            if (cacheFOSC != null)
                for (int idx = 0; idx < cacheFOSC.Length; idx++)
                    if (cacheFOSC[idx].Period == period && cacheFOSC[idx].EqualsInput(input))
                        return cacheFOSC[idx];

            lock (checkFOSC)
            {
                checkFOSC.Period = period;
                period = checkFOSC.Period;

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

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

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