From 2b10c889bc8c2a0ecbc712db72ee952e61ea73b5 Mon Sep 17 00:00:00 2001 From: jackyu66git Date: Sat, 21 Mar 2026 01:40:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E5=9E=8B=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChanKLC.py | 49 ++++++++++++++++++++++++++++++++++++++++--------- TF_DF.py | 1 + 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/ChanKLC.py b/ChanKLC.py index 1999dd3..fd97864 100644 --- a/ChanKLC.py +++ b/ChanKLC.py @@ -70,6 +70,8 @@ class ChanKLC(): self.ema5 = klu.ema5 self.ma5 = klu.ma5 self.fx_box = None + self.in_fx = False + self.fx_confirmed = False # ==================== EMA 通用计算方法 ==================== @staticmethod @@ -333,25 +335,54 @@ class ChanKLC(): high = 0 low = 0 display = False - if self.pre and self.next: + if self.pre and self.next and self.next.end_time: + self.next.in_fx = True if self.fx == Chan_FX_TYPE.TOP: - start_time = self.pre.start_time + start_time = self.pre.end_time end_time = self.next.end_time high = self.high low = self.pre.low if self.pre.low < self.next.low else self.next.low - if self.next.close < self.pre.open: + if self.next.close < self.pre.low: display = True elif self.fx == Chan_FX_TYPE.BOTTOM: - start_time = self.pre.start_time + start_time = self.pre.end_time end_time = self.next.end_time high = self.pre.high if self.pre.high > self.next.high else self.next.high low = self.low - if self.next.close > self.pre.open: + if self.next.close > self.pre.high: display = True - if high > 0 and display: - print(start_time, end_time, high, low) + if high > 0 and self.next.end_time and display: + #print(start_time, end_time, high, low) # Chan_FX_BOX 这里导入的是模块,类名在模块内部为 Chan_FX_Box + self.fx_confirmed = True self.fx_box = Chan_FX_Box.Chan_FX_Box(start_time, end_time, high, low) + def check_fx_confirmed(self, last_top, last_bottom): + if last_top and last_bottom: + if last_top.index > last_bottom.index: + if self.in_fx == False and last_top.fx_confirmed == False: + pre = last_top.pre + if pre.low > self.close: + last_top.fx_confirmed = True + if last_top.fx_box: + last_top.fx_box.end_time = self.end_time + print(self.end_time, "fx_confirmed top") + else: + high = last_top.high + low = self.low + last_top.fx_box = Chan_FX_Box.Chan_FX_Box(last_top.pre.end_time, self.end_time, high, low) + print(self.end_time, "fx_confirmed new box top") + elif self.in_fx == False and last_bottom.fx_confirmed == False: + pre = last_bottom.pre + if pre.high < self.close: + last_bottom.fx_confirmed = True + if last_bottom.fx_box: + last_bottom.fx_box.end_time = self.end_time + print(self.end_time, "fx_confirmed bottom") + else: + high = self.high + low = last_bottom.low + last_bottom.fx_box = Chan_FX_Box.Chan_FX_Box(last_bottom.pre.end_time, self.end_time, high, low) + print(self.end_time, "fx_confirmed new box bottom") def add_klu(self, klu): self.klu_list.append(klu) def set_end_klu(self, klu): @@ -379,8 +410,8 @@ class ChanKLC(): self.close = self.high if self.close < self.low: self.close = self.low - if self.close > self.high: - self.close = self.high + if self.open < self.low: + self.open = self.low #print(self.end_time, self.open, self.close, self.high, self.low) #print(klu.time, klu.open, klu.close, klu.high, klu.low) def cal_fx(self): diff --git a/TF_DF.py b/TF_DF.py index a5f0e9b..e38f98b 100644 --- a/TF_DF.py +++ b/TF_DF.py @@ -920,6 +920,7 @@ class TF_DF(): last_bottom = None bi_klc_min = 4 for klc in klc_list: + klc.check_fx_confirmed(last_top, last_bottom) fx = self.check_fx(klc) if fx == Chan_FX_TYPE.TOP and False: if last_bottom: