public static bool IsMatchedUpDownPattern(LimitedList <double> yList, double upPrice, double downPrice, UpDownPatternEnum pattern) { string pattStr = EnumUtil.GetUpDownPatternToChars(pattern); if (pattStr.Length == 0) { return(false); } var list = yList.ToList(); if (list.Count < 3) { return(false); } string result = ""; string lastResult = ""; int idx = 0; try { if (list[0] < upPrice && list[0] > downPrice) { return(false); } for (; idx < list.Count; idx++) { if (upPrice <= list[idx] && lastResult != "U") { result += "U"; lastResult = "U"; } else if (downPrice >= list[idx] && lastResult != "D") { result += "D"; lastResult = "D"; } if (result.Length == pattStr.Length) { break; } } result = ReverseXor(result); return(result == pattStr); } catch (Exception) { return(false); } }
/// <summary> /// /// </summary> /// <param name="basePrice1">큰값</param> /// <param name="basePrice2">작은값</param> /// <param name="yList"></param> /// <returns></returns> public static bool IsBreakThroughUp(double basePrice1, double basePrice2, LimitedList <double> yList) { var list = yList.ToList(); if (list.Count < 3) { return(false); } var cPrice = list[0]; if (basePrice1 > cPrice) { return(false); } if (basePrice2 > cPrice) { return(false); } bool isUp1 = false; bool isUp2 = false; try { int idx = 0; for (; idx < list.Count - 2; idx++) { if (IsBreakThroughUp(basePrice1, list[idx], list[idx + 1], list[idx + 2])) { isUp1 = true; break; } } for (; idx < list.Count - 2; idx++) { if (IsBreakThroughUp(basePrice2, list[idx], list[idx + 1], list[idx + 2])) { isUp2 = true; break; } } if (isUp1 && isUp2) { return(true); } } catch (Exception) { } return(false); }
public static bool IsBreakThroughUp(double basePrice, LimitedList <double> yList) { var list = yList.ToList(); if (list.Count < 3) { return(false); } var cPrice = list[0]; var y2 = list[1]; var y3 = list[2]; return(IsBreakThroughUp(basePrice, cPrice, y2, y3)); }
public static UpDownPatternEnum GetOneLineUpDownPatternL(LimitedList <double> yList) { UpDownPatternEnum upDownPattern = UpDownPatternEnum.None; var list = yList.ToList(); if (list.Count < 10) { return(upDownPattern); } double avgPoint = list.Average(); double highAvgPoint = (list.Max() + avgPoint) / 2.0; double lowAvgPoint = (list.Min() + avgPoint) / 2.0; return(GetUpDownPattern(yList, lowAvgPoint)); }
public static bool IsBreakThroughUpDown(double basePrice, LimitedList <double> yList) { var list = yList.ToList(); if (list.Count < 3) { return(false); } var cPrice = list[0]; if (basePrice < cPrice) { return(false); } try { bool isDown = false; bool isUp = false; int idx = 0; for (; idx < list.Count; idx++) { if (basePrice >= list[idx]) { isDown = true; break; } } for (; idx < list.Count; idx++) { if (basePrice <= list[idx]) { isUp = true; break; } } if (isDown && isUp) { return(true); } } catch (Exception) { } return(false); }
public static UpDownPatternEnum GetUpDownPattern(LimitedList <double> yList, List <double> upPrices, List <double> downPrices) { UpDownPatternEnum upDownPattern = UpDownPatternEnum.None; var list = yList.ToList(); if (list.Count < 3) { return(upDownPattern); } upPrices.Remove(0); upPrices.Remove(0); upPrices.Remove(0); downPrices.Remove(0); downPrices.Remove(0); downPrices.Remove(0); string result = ""; string lastResult = ""; int idx = 0; int pIdx = upPrices.Count - 1; int totalMatched = 0; try { if (list[0] < upPrices[0] && list[0] > downPrices[0]) { return(upDownPattern); } for (; pIdx >= 0; pIdx--) { double upPrice = upPrices[pIdx]; double downPrice = downPrices[pIdx]; int matched = 0; for (; idx < list.Count; idx++) { if (upPrice <= list[idx] && lastResult != "U") { result += "U"; lastResult = "U"; matched++; } else if (downPrice >= list[idx] && lastResult != "D") { result += "D"; lastResult = "D"; matched++; } if (matched == 2) { totalMatched++; break; } } if (result.Length == (upPrices.Count * 2) + 1) { break; } } if (pIdx == -1) { result = ReverseXor(result); if (result == "UDUDUDU") { upDownPattern = UpDownPatternEnum.UpDownUpDownUpDownUp; } else if (result == "DUDUDUD") { upDownPattern = UpDownPatternEnum.DownUpDownUpDownUpDown; } else if (result == "UDUDUD") { upDownPattern = UpDownPatternEnum.UpDownUpDownUpDown; } else if (result == "DUDUDU") { upDownPattern = UpDownPatternEnum.DownUpDownUpDownUp; } else if (result == "UDUDU") { upDownPattern = UpDownPatternEnum.UpDownUpDownUp; } else if (result == "DUDUD") { upDownPattern = UpDownPatternEnum.DownUpDownUpDown; } else if (result == "UDUD") { upDownPattern = UpDownPatternEnum.UpDownUpDown; } else if (result == "DUDU") { upDownPattern = UpDownPatternEnum.DownUpDownUp; } else if (result == "UDU") { upDownPattern = UpDownPatternEnum.UpDownUp; } else if (result == "DUD") { upDownPattern = UpDownPatternEnum.DownUpDown; } else if (result == "UD") { upDownPattern = UpDownPatternEnum.UpDown; } else if (result == "DU") { upDownPattern = UpDownPatternEnum.DownUp; } else if (result == "U") { upDownPattern = UpDownPatternEnum.Up; } else if (result == "D") { upDownPattern = UpDownPatternEnum.Down; } } } catch (Exception) { } return(upDownPattern); }
public static UpDownPatternEnum GetUpDownPattern(LimitedList <double> yList, double upPrice, double downPrice) { UpDownPatternEnum upDownPattern = UpDownPatternEnum.None; var list = yList.ToList(); if (list.Count < 3) { return(upDownPattern); } string result = ""; string lastResult = ""; int idx = 0; try { if (list[0] < upPrice && list[0] > downPrice) { return(upDownPattern); } for (; idx < list.Count; idx++) { if (upPrice <= list[idx] && lastResult != "U") { result += "U"; lastResult = "U"; } else if (downPrice >= list[idx] && lastResult != "D") { result += "D"; lastResult = "D"; } if (result.Length >= 7) { result = result.Substring(0, 7); break; } } result = ReverseXor(result); if (result == "UDUDUDU") { upDownPattern = UpDownPatternEnum.UpDownUpDownUpDownUp; } else if (result == "DUDUDUD") { upDownPattern = UpDownPatternEnum.DownUpDownUpDownUpDown; } else if (result == "UDUDUD") { upDownPattern = UpDownPatternEnum.UpDownUpDownUpDown; } else if (result == "DUDUDU") { upDownPattern = UpDownPatternEnum.DownUpDownUpDownUp; } else if (result == "UDUDU") { upDownPattern = UpDownPatternEnum.UpDownUpDownUp; } else if (result == "DUDUD") { upDownPattern = UpDownPatternEnum.DownUpDownUpDown; } else if (result == "UDUD") { upDownPattern = UpDownPatternEnum.UpDownUpDown; } else if (result == "DUDU") { upDownPattern = UpDownPatternEnum.DownUpDownUp; } else if (result == "UDU") { upDownPattern = UpDownPatternEnum.UpDownUp; } else if (result == "DUD") { upDownPattern = UpDownPatternEnum.DownUpDown; } else if (result == "UD") { upDownPattern = UpDownPatternEnum.UpDown; } else if (result == "DU") { upDownPattern = UpDownPatternEnum.DownUp; } else if (result == "U") { upDownPattern = UpDownPatternEnum.Up; } else if (result == "D") { upDownPattern = UpDownPatternEnum.Down; } } catch (Exception) { } return(upDownPattern); }
public static bool IsMatchedUpDownPattern(LimitedList <double> yList, List <double> upPrices, List <double> downPrices, UpDownPatternEnum pattern) { string pattStr = EnumUtil.GetUpDownPatternToChars(pattern); if (pattStr.Length == 0) { return(false); } var list = yList.ToList(); if (list.Count < 3) { return(false); } upPrices.Remove(0); upPrices.Remove(0); upPrices.Remove(0); downPrices.Remove(0); downPrices.Remove(0); downPrices.Remove(0); string result = ""; string lastResult = ""; int idx = 0; int pIdx = upPrices.Count - 1; int totalMatched = 0; try { if (list[0] < upPrices[0] && list[0] > downPrices[0]) { return(false); } for (; pIdx >= 0; pIdx--) { double upPrice = upPrices[pIdx]; double downPrice = downPrices[pIdx]; int matched = 0; for (; idx < list.Count; idx++) { if (upPrice <= list[idx] && lastResult != "U") { result += "U"; lastResult = "U"; matched++; } else if (downPrice >= list[idx] && lastResult != "D") { result += "D"; lastResult = "D"; matched++; } if (matched == 2) { totalMatched++; break; } } if (result.Length == (upPrices.Count * 2) + 1) { break; } } if (pIdx == -1) { result = ReverseXor(result); return(result == pattStr); } return(false); } catch (Exception) { return(false); } }