public override void ApplyTo(StockSerie stockSerie) { FloatSerie cciSerie = stockSerie.CalculateCCI((int)this.parameters[0]); int period1 = ((int)this.parameters[1]); int period2 = ((int)this.parameters[2]); cciSerie = period1 <= 1 ? cciSerie : cciSerie.CalculateEMA(period1); this.series[0] = cciSerie; this.series[0].Name = this.Name; FloatSerie signalSerie = cciSerie.CalculateEMA(period2); this.series[1] = signalSerie; this.series[1].Name = this.series[0].Name + "_SIGNAL"; // Detecting events this.CreateEventSeries(stockSerie.Count); for (int i = 2; i < cciSerie.Count; i++) { this.eventSeries[0][i] = (cciSerie[i] > signalSerie[i]); this.eventSeries[1][i] = (cciSerie[i] < signalSerie[i]); this.eventSeries[2][i] = eventSeries[0][i] & !eventSeries[0][i - 1]; this.eventSeries[3][i] = eventSeries[1][i] & !eventSeries[1][i - 1]; } }
public override void ApplyTo(StockSerie stockSerie) { int period1 = ((int)this.parameters[1]); int period2 = ((int)this.parameters[2]); float sigma = ((float)this.parameters[3]); FloatSerie cciSerie = stockSerie.CalculateCCI((int)this.parameters[0]).CalculateEMA(period1); this.series[0] = cciSerie = cciSerie.CalculateSigmoid(100f, sigma); this.series[0].Name = this.Name; FloatSerie signalSerie = cciSerie.CalculateEMA(period2); this.series[1] = signalSerie; this.series[1].Name = this.series[0].Name + "_SIGNAL"; // Detecting events this.CreateEventSeries(stockSerie.Count); for (int i = 2; i < cciSerie.Count; i++) { this.eventSeries[0][i] = (cciSerie[i] >= signalSerie[i]); this.eventSeries[1][i] = (cciSerie[i] < signalSerie[i]); this.eventSeries[2][i] = eventSeries[0][i] & !eventSeries[0][i - 1]; this.eventSeries[3][i] = eventSeries[1][i] & !eventSeries[1][i - 1]; this.eventSeries[4][i] = cciSerie[i] >= 0; this.eventSeries[5][i] = cciSerie[i] < 0; } }