/// <summary> /// The Price Oscillator indicator shows the variation among two moving averages for the price of a security. /// </summary> /// <returns></returns> public PriceOscillator PriceOscillator(Data.IDataSeries input, int fast, int slow, int smooth) { if (cachePriceOscillator != null) { for (int idx = 0; idx < cachePriceOscillator.Length; idx++) { if (cachePriceOscillator[idx].Fast == fast && cachePriceOscillator[idx].Slow == slow && cachePriceOscillator[idx].Smooth == smooth && cachePriceOscillator[idx].EqualsInput(input)) { return(cachePriceOscillator[idx]); } } } lock (checkPriceOscillator) { checkPriceOscillator.Fast = fast; fast = checkPriceOscillator.Fast; checkPriceOscillator.Slow = slow; slow = checkPriceOscillator.Slow; checkPriceOscillator.Smooth = smooth; smooth = checkPriceOscillator.Smooth; if (cachePriceOscillator != null) { for (int idx = 0; idx < cachePriceOscillator.Length; idx++) { if (cachePriceOscillator[idx].Fast == fast && cachePriceOscillator[idx].Slow == slow && cachePriceOscillator[idx].Smooth == smooth && cachePriceOscillator[idx].EqualsInput(input)) { return(cachePriceOscillator[idx]); } } } PriceOscillator indicator = new PriceOscillator(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.Fast = fast; indicator.Slow = slow; indicator.Smooth = smooth; Indicators.Add(indicator); indicator.SetUp(); PriceOscillator[] tmp = new PriceOscillator[cachePriceOscillator == null ? 1 : cachePriceOscillator.Length + 1]; if (cachePriceOscillator != null) { cachePriceOscillator.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cachePriceOscillator = tmp; return(indicator); } }
/// <summary> /// The Price Oscillator indicator shows the variation among two moving averages for the price of a security. /// </summary> /// <returns></returns> public PriceOscillator PriceOscillator(Data.IDataSeries input, int fast, int slow, int smooth) { if (cachePriceOscillator != null) for (int idx = 0; idx < cachePriceOscillator.Length; idx++) if (cachePriceOscillator[idx].Fast == fast && cachePriceOscillator[idx].Slow == slow && cachePriceOscillator[idx].Smooth == smooth && cachePriceOscillator[idx].EqualsInput(input)) return cachePriceOscillator[idx]; lock (checkPriceOscillator) { checkPriceOscillator.Fast = fast; fast = checkPriceOscillator.Fast; checkPriceOscillator.Slow = slow; slow = checkPriceOscillator.Slow; checkPriceOscillator.Smooth = smooth; smooth = checkPriceOscillator.Smooth; if (cachePriceOscillator != null) for (int idx = 0; idx < cachePriceOscillator.Length; idx++) if (cachePriceOscillator[idx].Fast == fast && cachePriceOscillator[idx].Slow == slow && cachePriceOscillator[idx].Smooth == smooth && cachePriceOscillator[idx].EqualsInput(input)) return cachePriceOscillator[idx]; PriceOscillator indicator = new PriceOscillator(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.Fast = fast; indicator.Slow = slow; indicator.Smooth = smooth; Indicators.Add(indicator); indicator.SetUp(); PriceOscillator[] tmp = new PriceOscillator[cachePriceOscillator == null ? 1 : cachePriceOscillator.Length + 1]; if (cachePriceOscillator != null) cachePriceOscillator.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cachePriceOscillator = tmp; return indicator; } }