/// <summary> /// The Stochastic Oscillator is made up of two lines that oscillate between a vertical scale of 0 to 100. The %K is the main line and it is drawn as a solid line. The second is the %D line and is a moving average of %K. The %D line is drawn as a dotted line. Use as a buy/sell signal generator, buying when fast moves above slow and selling when fast moves below slow. /// </summary> /// <returns></returns> public StochasticsFast StochasticsFast(Data.IDataSeries input, int periodD, int periodK) { if (cacheStochasticsFast != null) { for (int idx = 0; idx < cacheStochasticsFast.Length; idx++) { if (cacheStochasticsFast[idx].PeriodD == periodD && cacheStochasticsFast[idx].PeriodK == periodK && cacheStochasticsFast[idx].EqualsInput(input)) { return(cacheStochasticsFast[idx]); } } } lock (checkStochasticsFast) { checkStochasticsFast.PeriodD = periodD; periodD = checkStochasticsFast.PeriodD; checkStochasticsFast.PeriodK = periodK; periodK = checkStochasticsFast.PeriodK; if (cacheStochasticsFast != null) { for (int idx = 0; idx < cacheStochasticsFast.Length; idx++) { if (cacheStochasticsFast[idx].PeriodD == periodD && cacheStochasticsFast[idx].PeriodK == periodK && cacheStochasticsFast[idx].EqualsInput(input)) { return(cacheStochasticsFast[idx]); } } } StochasticsFast indicator = new StochasticsFast(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.PeriodD = periodD; indicator.PeriodK = periodK; Indicators.Add(indicator); indicator.SetUp(); StochasticsFast[] tmp = new StochasticsFast[cacheStochasticsFast == null ? 1 : cacheStochasticsFast.Length + 1]; if (cacheStochasticsFast != null) { cacheStochasticsFast.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheStochasticsFast = tmp; return(indicator); } }
/// <summary> /// The Stochastic Oscillator is made up of two lines that oscillate between a vertical scale of 0 to 100. The %K is the main line and it is drawn as a solid line. The second is the %D line and is a moving average of %K. The %D line is drawn as a dotted line. Use as a buy/sell signal generator, buying when fast moves above slow and selling when fast moves below slow. /// </summary> /// <returns></returns> public StochasticsFast StochasticsFast(Data.IDataSeries input, int periodD, int periodK) { if (cacheStochasticsFast != null) for (int idx = 0; idx < cacheStochasticsFast.Length; idx++) if (cacheStochasticsFast[idx].PeriodD == periodD && cacheStochasticsFast[idx].PeriodK == periodK && cacheStochasticsFast[idx].EqualsInput(input)) return cacheStochasticsFast[idx]; lock (checkStochasticsFast) { checkStochasticsFast.PeriodD = periodD; periodD = checkStochasticsFast.PeriodD; checkStochasticsFast.PeriodK = periodK; periodK = checkStochasticsFast.PeriodK; if (cacheStochasticsFast != null) for (int idx = 0; idx < cacheStochasticsFast.Length; idx++) if (cacheStochasticsFast[idx].PeriodD == periodD && cacheStochasticsFast[idx].PeriodK == periodK && cacheStochasticsFast[idx].EqualsInput(input)) return cacheStochasticsFast[idx]; StochasticsFast indicator = new StochasticsFast(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.PeriodD = periodD; indicator.PeriodK = periodK; Indicators.Add(indicator); indicator.SetUp(); StochasticsFast[] tmp = new StochasticsFast[cacheStochasticsFast == null ? 1 : cacheStochasticsFast.Length + 1]; if (cacheStochasticsFast != null) cacheStochasticsFast.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheStochasticsFast = tmp; return indicator; } }