添加分型确认
This commit is contained in:
+40
-9
@@ -70,6 +70,8 @@ class ChanKLC():
|
|||||||
self.ema5 = klu.ema5
|
self.ema5 = klu.ema5
|
||||||
self.ma5 = klu.ma5
|
self.ma5 = klu.ma5
|
||||||
self.fx_box = None
|
self.fx_box = None
|
||||||
|
self.in_fx = False
|
||||||
|
self.fx_confirmed = False
|
||||||
# ==================== EMA 通用计算方法 ====================
|
# ==================== EMA 通用计算方法 ====================
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -333,25 +335,54 @@ class ChanKLC():
|
|||||||
high = 0
|
high = 0
|
||||||
low = 0
|
low = 0
|
||||||
display = False
|
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:
|
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
|
end_time = self.next.end_time
|
||||||
high = self.high
|
high = self.high
|
||||||
low = self.pre.low if self.pre.low < self.next.low else self.next.low
|
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
|
display = True
|
||||||
elif self.fx == Chan_FX_TYPE.BOTTOM:
|
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
|
end_time = self.next.end_time
|
||||||
high = self.pre.high if self.pre.high > self.next.high else self.next.high
|
high = self.pre.high if self.pre.high > self.next.high else self.next.high
|
||||||
low = self.low
|
low = self.low
|
||||||
if self.next.close > self.pre.open:
|
if self.next.close > self.pre.high:
|
||||||
display = True
|
display = True
|
||||||
if high > 0 and display:
|
if high > 0 and self.next.end_time and display:
|
||||||
print(start_time, end_time, high, low)
|
#print(start_time, end_time, high, low)
|
||||||
# Chan_FX_BOX 这里导入的是模块,类名在模块内部为 Chan_FX_Box
|
# 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)
|
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):
|
def add_klu(self, klu):
|
||||||
self.klu_list.append(klu)
|
self.klu_list.append(klu)
|
||||||
def set_end_klu(self, klu):
|
def set_end_klu(self, klu):
|
||||||
@@ -379,8 +410,8 @@ class ChanKLC():
|
|||||||
self.close = self.high
|
self.close = self.high
|
||||||
if self.close < self.low:
|
if self.close < self.low:
|
||||||
self.close = self.low
|
self.close = self.low
|
||||||
if self.close > self.high:
|
if self.open < self.low:
|
||||||
self.close = self.high
|
self.open = self.low
|
||||||
#print(self.end_time, self.open, self.close, self.high, 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)
|
#print(klu.time, klu.open, klu.close, klu.high, klu.low)
|
||||||
def cal_fx(self):
|
def cal_fx(self):
|
||||||
|
|||||||
@@ -920,6 +920,7 @@ class TF_DF():
|
|||||||
last_bottom = None
|
last_bottom = None
|
||||||
bi_klc_min = 4
|
bi_klc_min = 4
|
||||||
for klc in klc_list:
|
for klc in klc_list:
|
||||||
|
klc.check_fx_confirmed(last_top, last_bottom)
|
||||||
fx = self.check_fx(klc)
|
fx = self.check_fx(klc)
|
||||||
if fx == Chan_FX_TYPE.TOP and False:
|
if fx == Chan_FX_TYPE.TOP and False:
|
||||||
if last_bottom:
|
if last_bottom:
|
||||||
|
|||||||
Reference in New Issue
Block a user