private void GeneratePattern() { if (Index > 2) { DetectedPatterns.Add(Index, new List <KeyValuePair <string, bool> >() { new KeyValuePair <string, bool>("IsBearish", this.IndexedCandle.IsBearish()), new KeyValuePair <string, bool>("IsBullish", this.IndexedCandle.IsBullish()), new KeyValuePair <string, bool>("IsAccumDistBearish", this.IndexedCandle.IsAccumDistBearish()), new KeyValuePair <string, bool>("IsAccumDistBullish", this.IndexedCandle.IsAccumDistBullish()), new KeyValuePair <string, bool>("IsBreakingHistoricalHighestClose", this.IndexedCandle.IsBreakingHistoricalHighestClose()), new KeyValuePair <string, bool>("IsBreakingHistoricalHighestHigh", this.IndexedCandle.IsBreakingHistoricalHighestHigh()), new KeyValuePair <string, bool>("IsBreakingHistoricalLowestLow", this.IndexedCandle.IsBreakingHistoricalLowestLow()), new KeyValuePair <string, bool>("IsBreakingHistoricalLowestClose", this.IndexedCandle.IsBreakingHistoricalLowestClose()), new KeyValuePair <string, bool>("IsObvBullish", this.IndexedCandle.IsObvBullish()), new KeyValuePair <string, bool>("IsObvBearish", this.IndexedCandle.IsObvBearish()), }); //Isolate true cases (false are still available by object copy on event args) var AnyOfPatternTrue = DetectedPatterns[Index].Where(y => y.Value == true); //Send signal foreach (var psignalin in AnyOfPatternTrue) { switch (psignalin.Key) { case "IsBearish": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsBearish, this.Candles.Last(), this)); break; case "IsBullish": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsBullish, this.Candles.Last(), this)); break; case "IsAccumDistBearish": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsAccumDistBearish, this.Candles.Last(), this)); break; case "IsAccumDistBullish": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsAccumDistBullish, this.Candles.Last(), this)); break; case "IsBreakingHistoricalHighestClose": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsBreakingHistoricalHighestClose, this.Candles.Last(), this)); break; case "IsBreakingHistoricalHighestHigh": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsBreakingHistoricalHighestHigh, this.Candles.Last(), this)); break; case "IsBreakingHistoricalLowestLow": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsBreakingHistoricalLowestLow, this.Candles.Last(), this)); break; case "IsBreakingHistoricalLowestClose": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsBreakingHistoricalLowestClose, this.Candles.Last(), this)); break; case "IsObvBullish": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsObvBullish, this.Candles.Last(), this)); break; case "IsObvBearish": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsObvBearish, this.Candles.Last(), this)); break; } } } }
private void GeneratePattern() { if (Index > 2) { if (DefaultPatternLongPeriod < Index - 1) { DetectedPatterns.Add(Index, new List <KeyValuePair <string, bool> >() { new KeyValuePair <string, bool>("IsBearish", this.IndexedCandle.IsBearish()), new KeyValuePair <string, bool>("IsBullish", this.IndexedCandle.IsBullish()), new KeyValuePair <string, bool>("IsAccumDistBearish", this.IndexedCandle.IsAccumDistBearish()), new KeyValuePair <string, bool>("IsAccumDistBullish", this.IndexedCandle.IsAccumDistBullish()), new KeyValuePair <string, bool>("IsBreakingHistoricalHighestClose", this.IndexedCandle.IsBreakingHistoricalHighestClose()), new KeyValuePair <string, bool>("IsBreakingHistoricalHighestHigh", this.IndexedCandle.IsBreakingHistoricalHighestHigh()), new KeyValuePair <string, bool>("IsBreakingHistoricalLowestLow", this.IndexedCandle.IsBreakingHistoricalLowestLow()), new KeyValuePair <string, bool>("IsBreakingHistoricalLowestClose", this.IndexedCandle.IsBreakingHistoricalLowestClose()), new KeyValuePair <string, bool>("IsObvBullish", this.IndexedCandle.IsObvBullish()), new KeyValuePair <string, bool>("IsObvBearish", this.IndexedCandle.IsObvBearish()), new KeyValuePair <string, bool>("IsRsiOverbought", this.IndexedCandle.IsRsiOverbought(DefaultPatternPeriod)), new KeyValuePair <string, bool>("IsRsiOversold", this.IndexedCandle.IsRsiOversold(DefaultPatternPeriod)), new KeyValuePair <string, bool>("IsSmaBullishCross", this.IndexedCandle.IsSmaBullishCross(DefaultPatternPeriod, DefaultPatternLongPeriod)), new KeyValuePair <string, bool>("IsSmaBearishCross", this.IndexedCandle.IsSmaBearishCross(DefaultPatternPeriod, DefaultPatternLongPeriod)), new KeyValuePair <string, bool>("IsEmaBullish", this.IndexedCandle.IsEmaBullish(DefaultPatternPeriod)), new KeyValuePair <string, bool>("IsEmaBearish", this.IndexedCandle.IsEmaBearish(DefaultPatternPeriod)), new KeyValuePair <string, bool>("IsAboveEma", this.IndexedCandle.IsAboveEma(DefaultPatternPeriod)), new KeyValuePair <string, bool>("IsBelowEma", this.IndexedCandle.IsBelowEma(DefaultPatternPeriod)), new KeyValuePair <string, bool>("IsEmaBullishCross", this.IndexedCandle.IsEmaBullishCross(DefaultPatternPeriod, DefaultPatternLongPeriod)), new KeyValuePair <string, bool>("IsEmaBearishCross", this.IndexedCandle.IsEmaBearishCross(DefaultPatternPeriod, DefaultPatternLongPeriod)), new KeyValuePair <string, bool>("IsBreakingHighestHighPeriod", this.IndexedCandle.IsBreakingHighestHigh(DefaultPatternPeriod)), new KeyValuePair <string, bool>("IsBreakingHighestClosePeriod", this.IndexedCandle.IsBreakingHighestClose(DefaultPatternPeriod)), new KeyValuePair <string, bool>("IsBreakingLowestLowPeriod", this.IndexedCandle.IsBreakingLowestLow(DefaultPatternPeriod)), new KeyValuePair <string, bool>("IsBreakingLowestClosePeriod", this.IndexedCandle.IsBreakingLowestClose(DefaultPatternPeriod)), }); } else { DetectedPatterns.Add(Index, new List <KeyValuePair <string, bool> >() { new KeyValuePair <string, bool>("IsBearish", this.IndexedCandle.IsBearish()), new KeyValuePair <string, bool>("IsBullish", this.IndexedCandle.IsBullish()), new KeyValuePair <string, bool>("IsAccumDistBearish", this.IndexedCandle.IsAccumDistBearish()), new KeyValuePair <string, bool>("IsAccumDistBullish", this.IndexedCandle.IsAccumDistBullish()), new KeyValuePair <string, bool>("IsBreakingHistoricalHighestClose", this.IndexedCandle.IsBreakingHistoricalHighestClose()), new KeyValuePair <string, bool>("IsBreakingHistoricalHighestHigh", this.IndexedCandle.IsBreakingHistoricalHighestHigh()), new KeyValuePair <string, bool>("IsBreakingHistoricalLowestLow", this.IndexedCandle.IsBreakingHistoricalLowestLow()), new KeyValuePair <string, bool>("IsBreakingHistoricalLowestClose", this.IndexedCandle.IsBreakingHistoricalLowestClose()), new KeyValuePair <string, bool>("IsObvBullish", this.IndexedCandle.IsObvBullish()), new KeyValuePair <string, bool>("IsObvBearish", this.IndexedCandle.IsObvBearish()), }); } //Isolate true cases (false are still available by object copy on event args) var AnyOfPatternTrue = DetectedPatterns[Index].Where(y => y.Value == true); //Send signal foreach (var psignalin in AnyOfPatternTrue) { switch (psignalin.Key) { case "IsBearish": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsBearish, this.Candles.Last(), this)); break; case "IsBullish": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsBullish, this.Candles.Last(), this)); break; case "IsAccumDistBearish": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsAccumDistBearish, this.Candles.Last(), this)); break; case "IsAccumDistBullish": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsAccumDistBullish, this.Candles.Last(), this)); break; case "IsBreakingHistoricalHighestClose": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsBreakingHistoricalHighestClose, this.Candles.Last(), this)); break; case "IsBreakingHistoricalHighestHigh": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsBreakingHistoricalHighestHigh, this.Candles.Last(), this)); break; case "IsBreakingHistoricalLowestLow": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsBreakingHistoricalLowestLow, this.Candles.Last(), this)); break; case "IsBreakingHistoricalLowestClose": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsBreakingHistoricalLowestClose, this.Candles.Last(), this)); break; case "IsObvBullish": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsObvBullish, this.Candles.Last(), this)); break; case "IsObvBearish": PatternUpdate?.Invoke(this, new PatternEvent(PatternType.IsObvBearish, this.Candles.Last(), this)); break; } } } }