public Cross Crosses(TimeSeries series, DateTime dateTime) { var num = IndexOf(dateTime); var num2 = series.IndexOf(dateTime); if (num <= 0 || num >= this.series.Count) { return Cross.None; } if (num2 > 0 && num2 < series.Count) { DateTime dateTime2 = GetDateTime(num - 1); DateTime dateTime3 = series.GetDateTime(num2 - 1); if (dateTime2 == dateTime3) { if (this.GetValue(num - 1) <= series.GetValue(num2 - 1) && this.GetValue(num) > series.GetValue(num2)) { return Cross.Above; } if (this.GetValue(num - 1) >= series.GetValue(num2 - 1) && this.GetValue(num) < series.GetValue(num2)) { return Cross.Below; } } else { double value; double value2; if (dateTime2 < dateTime3) { DateTime dateTime4 = this.GetDateTime(num - 1); value = this.GetValue(num - 1); if (series.IndexOf(dateTime4, SearchOption.Next) != num2) { value2 = series.GetValue(series.IndexOf(dateTime4, SearchOption.Next)); } else { value2 = series.GetValue(series.IndexOf(dateTime4, SearchOption.Prev)); } } else { DateTime dateTime5 = series.GetDateTime(num2 - 1); value2 = series.GetValue(num2 - 1); if (this.IndexOf(dateTime5, SearchOption.Prev) != num) { value = this.GetValue(this.IndexOf(dateTime5, SearchOption.Next)); } else { value = this.GetValue(this.IndexOf(dateTime5, SearchOption.Prev)); } } if (value <= value2 && this.GetValue(num) > series.GetValue(num2)) { return Cross.Above; } if (value >= value2 && this.GetValue(num) < series.GetValue(num2)) { return Cross.Below; } } return Cross.None; } return Cross.None; }
public Cross Crosses(TimeSeries series, DateTime dateTime) { var num = IndexOf(dateTime); var num2 = series.IndexOf(dateTime); if (num <= 0 || num >= this.series.Count) { return(Cross.None); } if (num2 > 0 && num2 < series.Count) { DateTime dateTime2 = GetDateTime(num - 1); DateTime dateTime3 = series.GetDateTime(num2 - 1); if (dateTime2 == dateTime3) { if (this.GetValue(num - 1) <= series.GetValue(num2 - 1) && this.GetValue(num) > series.GetValue(num2)) { return(Cross.Above); } if (this.GetValue(num - 1) >= series.GetValue(num2 - 1) && this.GetValue(num) < series.GetValue(num2)) { return(Cross.Below); } } else { double value; double value2; if (dateTime2 < dateTime3) { DateTime dateTime4 = this.GetDateTime(num - 1); value = this.GetValue(num - 1); if (series.IndexOf(dateTime4, SearchOption.Next) != num2) { value2 = series.GetValue(series.IndexOf(dateTime4, SearchOption.Next)); } else { value2 = series.GetValue(series.IndexOf(dateTime4, SearchOption.Prev)); } } else { DateTime dateTime5 = series.GetDateTime(num2 - 1); value2 = series.GetValue(num2 - 1); if (this.IndexOf(dateTime5, SearchOption.Prev) != num) { value = this.GetValue(this.IndexOf(dateTime5, SearchOption.Next)); } else { value = this.GetValue(this.IndexOf(dateTime5, SearchOption.Prev)); } } if (value <= value2 && this.GetValue(num) > series.GetValue(num2)) { return(Cross.Above); } if (value >= value2 && this.GetValue(num) < series.GetValue(num2)) { return(Cross.Below); } } return(Cross.None); } return(Cross.None); }