public static bool AnalyseSR(List <double> lst, Criterion cri, List <Extreme> extremes) { List <double> headlist = lst.GetRange(lst.Count() - cri.HeadPeriod, cri.HeadPeriod); List <double> taillist = lst.GetRange(0, cri.TailPeriod); double before = -99999; double next = 99999; foreach (Extreme ex in extremes) { if (ex.Level > headlist.Last() && ex.Level < next) { next = ex.Level; } if (ex.Level < headlist.Last() && ex.Level > before) { before = ex.Level; } } double canal_width = Math.Round(((next - before) / before) * 100, 2); double position = Math.Round(((headlist.Last() - before) / (next - before)) * 100, 2); if (next == 99999) { return(true); } if (before == -99999 && cri.HeadSRPosition != Enum.SRPosition.N) { return(false); } switch (cri.HeadSRPosition) { case Enum.SRPosition.N: return(true); case Enum.SRPosition.U5: if (position > 5) { return(false); } break; case Enum.SRPosition.U10: if (position > 10) { return(false); } break; case Enum.SRPosition.U15: if (position > 15) { return(false); } break; case Enum.SRPosition.U20: if (position > 20) { return(false); } break; case Enum.SRPosition.U25: if (position > 25) { return(false); } break; case Enum.SRPosition.U30: if (position > 30) { return(false); } break; case Enum.SRPosition.U40: if (position > 40) { return(false); } break; case Enum.SRPosition.U50: if (position > 50) { return(false); } break; case Enum.SRPosition.U60: if (position > 60) { return(false); } break; case Enum.SRPosition.U70: if (position > 70) { return(false); } break; case Enum.SRPosition.U80: if (position > 80) { return(false); } break; case Enum.SRPosition.U90: if (position > 90) { return(false); } break; default: break; } return(true); }
public static bool AnalyseDerivativeDerivative(List <double> lst, Criterion cri, DataBundle db) { //try //{ List <double> headlist = lst.GetRange(lst.Count() - cri.HeadPeriod, cri.HeadPeriod); List <double> taillist = lst.GetRange(0, cri.TailPeriod - 1); if (db.Average == 0) { return(false); } if (cri.HeadSlope == Slope.Positive) { var result = headlist.Count(x => x < 0); if (result > 0) { return(false); } return(true); } else if (cri.HeadSlope == Slope.Negative) { var result = headlist.Count(x => x > 0); if (result > 0) { return(false); } return(true); } if (cri.TailSlope == Slope.Positive) { var result = headlist.Count(x => x < 0); if (result > 0) { return(false); } return(true); } else if (cri.TailSlope == Slope.Negative) { var result = headlist.Count(x => x > 0); if (result > 0) { return(false); } return(true); } return(true); //} //catch (Exception ex) //{ // return false; //} }
public static bool AnalyseAmount(List <double> lst, Criterion cri, DataBundle db) { List <double> headlist = lst.GetRange(lst.Count() - cri.HeadPeriod, cri.HeadPeriod); List <double> taillist = lst.GetRange(0, cri.TailPeriod); if (db.Average == 0) { return(false); } switch (cri.HeadAverageAmount) { case Enum.Amount.N: break; case Enum.Amount.BA: if (headlist.Average() > db.Average) { return(false); } break; case Enum.Amount.CTRH: if (PositionPercentage(headlist.Average(), db.RecordHigh) < 90) { return(false); } break; case Enum.Amount.CTRL: if (PositionPercentage(headlist.Average(), db.RecordHigh) > 10) { return(false); } break; case Enum.Amount.OOF: if (PositionPercentage(headlist.Average(), db.RecordHigh) < 20) { return(false); } break; case Enum.Amount.OTF: if (PositionPercentage(headlist.Average(), db.RecordHigh) < 40) { return(false); } break; case Enum.Amount.OTRF: if (PositionPercentage(headlist.Average(), db.RecordHigh) < 60) { return(false); } break; case Enum.Amount.OFF: if (PositionPercentage(headlist.Average(), db.RecordHigh) < 80) { return(false); } break; case Enum.Amount.OA: if (headlist.Average() < db.Average) { return(false); } break; case Enum.Amount.AA: if (headlist.Average() < db.Average + (db.Average * 0.1) && headlist.Average() > db.Average - (db.Average * 0.1)) { return(false); } break; } if (taillist.Count() > 0) { switch (cri.TailAverageAmount) { case Enum.Amount.N: break; case Enum.Amount.BA: if (taillist.Average() > db.Average) { return(false); } break; case Enum.Amount.CTRH: if (PositionPercentage(taillist.Average(), db.RecordHigh) < 90) { return(false); } break; case Enum.Amount.CTRL: if (PositionPercentage(taillist.Average(), db.RecordHigh) > 10) { return(false); } break; case Enum.Amount.OOF: if (PositionPercentage(taillist.Average(), db.RecordHigh) < 20) { return(false); } break; case Enum.Amount.OTF: if (PositionPercentage(taillist.Average(), db.RecordHigh) < 40) { return(false); } break; case Enum.Amount.OTRF: if (PositionPercentage(taillist.Average(), db.RecordHigh) < 60) { return(false); } break; case Enum.Amount.OFF: if (PositionPercentage(taillist.Average(), db.RecordHigh) < 80) { return(false); } break; case Enum.Amount.OA: if (taillist.Average() < db.Average) { return(false); } break; case Enum.Amount.AA: if (taillist.Average() < db.Average + (db.Average * 0.1) && taillist.Average() > db.Average - (db.Average * 0.1)) { return(false); } break; } } return(true); }