public override void ApplyTo(StockSerie stockSerie) { FloatSerie longStopSerie; FloatSerie shortStopSerie; FloatSerie highSerie = stockSerie.GetSerie(StockDataType.HIGH); FloatSerie lowSerie = stockSerie.GetSerie(StockDataType.LOW); stockSerie.CalculatePercentTrailStop( (float)this.Parameters[0]/100f, 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++) { this.Events[0][i] = !float.IsNaN(longStopSerie[i]); this.Events[1][i] = !float.IsNaN(shortStopSerie[i]); this.Events[2][i] = float.IsNaN(longStopSerie[i - 1]) && !float.IsNaN(longStopSerie[i]); this.Events[3][i] = float.IsNaN(shortStopSerie[i - 1]) && !float.IsNaN(shortStopSerie[i]); this.Events[4][i] = !float.IsNaN(longStopSerie[i - 1]) && !float.IsNaN(longStopSerie[i]) && longStopSerie[i - 1] < longStopSerie[i]; this.Events[5][i] = !float.IsNaN(shortStopSerie[i - 1]) && !float.IsNaN(shortStopSerie[i]) && shortStopSerie[i - 1] > shortStopSerie[i]; this.Events[6][i] = !float.IsNaN(longStopSerie[i]) && !float.IsNaN(longStopSerie[i - 1]) && lowSerie[i] > longStopSerie[i] && lowSerie[i - 1] <= longStopSerie[i - 1]; this.Events[7][i] = !float.IsNaN(shortStopSerie[i]) && !float.IsNaN(shortStopSerie[i - 1]) && highSerie[i] < shortStopSerie[i] && highSerie[i - 1] >= shortStopSerie[i - 1]; } }