/// <summary> /// The Hull Moving Average (HMA) employs weighted MA calculations to offer superior smoothing, and much less lag, over traditional SMA indicators. /// </summary> /// <returns></returns> public HMARick HMARick(Data.IDataSeries input, int period, int threshold) { if (cacheHMARick != null) { for (int idx = 0; idx < cacheHMARick.Length; idx++) { if (cacheHMARick[idx].Period == period && cacheHMARick[idx].Threshold == threshold && cacheHMARick[idx].EqualsInput(input)) { return(cacheHMARick[idx]); } } } lock (checkHMARick) { checkHMARick.Period = period; period = checkHMARick.Period; checkHMARick.Threshold = threshold; threshold = checkHMARick.Threshold; if (cacheHMARick != null) { for (int idx = 0; idx < cacheHMARick.Length; idx++) { if (cacheHMARick[idx].Period == period && cacheHMARick[idx].Threshold == threshold && cacheHMARick[idx].EqualsInput(input)) { return(cacheHMARick[idx]); } } } HMARick indicator = new HMARick(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.Period = period; indicator.Threshold = threshold; Indicators.Add(indicator); indicator.SetUp(); HMARick[] tmp = new HMARick[cacheHMARick == null ? 1 : cacheHMARick.Length + 1]; if (cacheHMARick != null) { cacheHMARick.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheHMARick = tmp; return(indicator); } }
protected override void OnStartUp() { signal = HMA(signalLinePeriod); dynamicTrend = HMARick(trendBand, Threshold); priceTrigger = SMARick(priceTriggerPeriod); slowSignal = SMA(slowSignalPeriod); dynamicTrend.DownColor = Color.Purple; dynamicTrend.UpColor = Color.DarkCyan; dynamicTrend.PaintPriceMarkers = false; // slowSignal.Plots[0].Pen.Color = Color.Red; // slowSignal.PaintPriceMarkers = false; // slowSignal.CalculateOnBarClose = false; }