private static int CompareExtremums(Extremum left, Extremum right) { if (left.DateTime > right.DateTime) return 1; if (left.DateTime < right.DateTime) return -1; /*if (left.CheckerIndex > right.CheckerIndex) return 1; if (left.CheckerIndex < right.CheckerIndex) return -1;*/ return 0; }
public Extremum AddExtremum(Extremum extremum) { var firstExtremums = extremum.IsMinimum ? firstMinimums : firstMaximums; if (firstExtremums.Contains(extremum)) return null; firstExtremums.Add(extremum); if (CompareExtremums(firstExtremums.GetLast(), extremum) != 0) return null; if (firstExtremums.Count < 3) return null; if (extremum.IsMinimum) return TryGetSecondMinimum(); return TryGetSecondMaximum(); }
private bool NeedToTrade(RobotContext context, Extremum secondExtremum) { var isTrendLong = IsTrendLong(context.Candles); context.Logger.Debug("NeedToTrade? extremum:{0}, trend:{1}", secondExtremum.IsMinimum, isTrendLong); return secondExtremum.IsMinimum == isTrendLong; }
private Extremum SaveSecondExtremum(Extremum mid, Extremum right) { var extremum = new Extremum(mid.Value, right.CheckerIndex, mid.DateTime, mid.IsMinimum); (mid.IsMinimum ? secondMinimums : secondMaximums).Add(extremum); return extremum; }