/// <summary> /// Plots % envelopes around a moving average /// </summary> /// <returns></returns> public MAEnvelopes MAEnvelopes(Data.IDataSeries input, double envelopePercentage, int mAType, int period) { if (cacheMAEnvelopes != null) { for (int idx = 0; idx < cacheMAEnvelopes.Length; idx++) { if (Math.Abs(cacheMAEnvelopes[idx].EnvelopePercentage - envelopePercentage) <= double.Epsilon && cacheMAEnvelopes[idx].MAType == mAType && cacheMAEnvelopes[idx].Period == period && cacheMAEnvelopes[idx].EqualsInput(input)) { return(cacheMAEnvelopes[idx]); } } } lock (checkMAEnvelopes) { checkMAEnvelopes.EnvelopePercentage = envelopePercentage; envelopePercentage = checkMAEnvelopes.EnvelopePercentage; checkMAEnvelopes.MAType = mAType; mAType = checkMAEnvelopes.MAType; checkMAEnvelopes.Period = period; period = checkMAEnvelopes.Period; if (cacheMAEnvelopes != null) { for (int idx = 0; idx < cacheMAEnvelopes.Length; idx++) { if (Math.Abs(cacheMAEnvelopes[idx].EnvelopePercentage - envelopePercentage) <= double.Epsilon && cacheMAEnvelopes[idx].MAType == mAType && cacheMAEnvelopes[idx].Period == period && cacheMAEnvelopes[idx].EqualsInput(input)) { return(cacheMAEnvelopes[idx]); } } } MAEnvelopes indicator = new MAEnvelopes(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.EnvelopePercentage = envelopePercentage; indicator.MAType = mAType; indicator.Period = period; Indicators.Add(indicator); indicator.SetUp(); MAEnvelopes[] tmp = new MAEnvelopes[cacheMAEnvelopes == null ? 1 : cacheMAEnvelopes.Length + 1]; if (cacheMAEnvelopes != null) { cacheMAEnvelopes.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheMAEnvelopes = tmp; return(indicator); } }
/// <summary> /// Plots % envelopes around a moving average /// </summary> /// <returns></returns> public MAEnvelopes MAEnvelopes(Data.IDataSeries input, double envelopePercentage, int mAType, int period) { if (cacheMAEnvelopes != null) for (int idx = 0; idx < cacheMAEnvelopes.Length; idx++) if (Math.Abs(cacheMAEnvelopes[idx].EnvelopePercentage - envelopePercentage) <= double.Epsilon && cacheMAEnvelopes[idx].MAType == mAType && cacheMAEnvelopes[idx].Period == period && cacheMAEnvelopes[idx].EqualsInput(input)) return cacheMAEnvelopes[idx]; lock (checkMAEnvelopes) { checkMAEnvelopes.EnvelopePercentage = envelopePercentage; envelopePercentage = checkMAEnvelopes.EnvelopePercentage; checkMAEnvelopes.MAType = mAType; mAType = checkMAEnvelopes.MAType; checkMAEnvelopes.Period = period; period = checkMAEnvelopes.Period; if (cacheMAEnvelopes != null) for (int idx = 0; idx < cacheMAEnvelopes.Length; idx++) if (Math.Abs(cacheMAEnvelopes[idx].EnvelopePercentage - envelopePercentage) <= double.Epsilon && cacheMAEnvelopes[idx].MAType == mAType && cacheMAEnvelopes[idx].Period == period && cacheMAEnvelopes[idx].EqualsInput(input)) return cacheMAEnvelopes[idx]; MAEnvelopes indicator = new MAEnvelopes(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.EnvelopePercentage = envelopePercentage; indicator.MAType = mAType; indicator.Period = period; Indicators.Add(indicator); indicator.SetUp(); MAEnvelopes[] tmp = new MAEnvelopes[cacheMAEnvelopes == null ? 1 : cacheMAEnvelopes.Length + 1]; if (cacheMAEnvelopes != null) cacheMAEnvelopes.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheMAEnvelopes = tmp; return indicator; } }