public override void ApplyTo(StockSerie stockSerie) { FloatSerie longStopSerie; FloatSerie shortStopSerie; FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW); FloatSerie HighSerie = stockSerie.GetSerie(StockDataType.HIGH); IStockIndicator bbIndicator = stockSerie.GetIndicator(this.Name.Replace("TRAIL", "")); stockSerie.CalculateBBTrailStop(bbIndicator.Series[1], bbIndicator.Series[0], out longStopSerie, out shortStopSerie); this.Series[0] = longStopSerie; this.Series[1] = shortStopSerie; // Detecting events this.CreateEventSeries(stockSerie.Count); for (int i = 5; i < stockSerie.Count; i++) { bool upTrend; this.Events[0][i] = upTrend = float.IsNaN(shortStopSerie[i]); this.Events[1][i] = !upTrend; this.Events[2][i] = upTrend && !this.Events[0][i - 1]; this.Events[3][i] = !upTrend && !this.Events[1][i - 1]; this.Events[4][i] = upTrend && this.Events[0][i - 1] && lowSerie[i - 1] <= longStopSerie[i - 1] && lowSerie[i] > longStopSerie[i]; this.Events[5][i] = !upTrend && this.Events[1][i - 1] && HighSerie[i - 1] >= shortStopSerie[i - 1] && HighSerie[i] < shortStopSerie[i]; ; } }