SD不需要结束就显示出来,要不然滞后太严重了
This commit is contained in:
@@ -54,6 +54,7 @@ class ChanKLU:
|
||||
|
||||
self.continue_div = False
|
||||
self.separate_div = False
|
||||
self.near0_return = 0
|
||||
self.ema52 = 0
|
||||
self.ema24 = 0
|
||||
self.macd_slop = 0
|
||||
@@ -680,22 +681,27 @@ class ChanKLU:
|
||||
# 完美形态:白线接近零轴 + 价格触碰/轻破EMA52 + 黄线不穿零轴
|
||||
if abs(self.macd) <= NEAR0_EPS and touch_52 and (not (self.pre.signal >= 0 and self.signal < 0)) and (not (self.pre.signal <= 0 and self.signal > 0)):
|
||||
self.macd_state = Chan_MACD_STATE.NEAR0_PERFECT
|
||||
#self.near0_return = 1
|
||||
return self.macd_state
|
||||
# EMA24 附近
|
||||
if lines_near_zero and touch_24:
|
||||
self.macd_state = Chan_MACD_STATE.NEAR0_24
|
||||
#self.near0_return = 2
|
||||
return self.macd_state
|
||||
# EMA52 附近
|
||||
if lines_near_zero and touch_52:
|
||||
self.macd_state = Chan_MACD_STATE.NEAR0_52
|
||||
#self.near0_return = 3
|
||||
return self.macd_state
|
||||
# 白线接近零轴但价格未至EMA52
|
||||
if abs(self.macd) <= NEAR0_EPS and not touch_52:
|
||||
self.macd_state = Chan_MACD_STATE.NEAR0_DIFF
|
||||
#self.near0_return = 4
|
||||
return self.macd_state
|
||||
# 一般近零轴
|
||||
if lines_near_zero or touch_52:
|
||||
self.macd_state = Chan_MACD_STATE.NEAR0
|
||||
#self.near0_return = 5
|
||||
return self.macd_state
|
||||
# 穿零轴后离开零轴
|
||||
if self.pre.macd_state == Chan_MACD_STATE.CROSS0_UP and ((self.macd >= self.pre.macd and self.signal >= self.pre.signal) or (abs(self.macdhist) >= abs(self.pre.macdhist))):
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ class ChanMACD():
|
||||
last_seg.add_klu(klu)
|
||||
last_klu = klu
|
||||
klu.cal_macd_state()
|
||||
print(klu.time, klu.macd_state, klu.continue_div, klu.separate_div, klu.macd, klu.signal, klu.macdhist, klu.ema24, klu.ema52, klu.close)
|
||||
#print(klu.time, klu.macd_state, klu.continue_div, klu.separate_div, klu.macd, klu.signal, klu.macdhist, klu.ema24, klu.ema52, klu.close)
|
||||
if last_histset:
|
||||
last_histset.set_end_klu(last_klu)
|
||||
if last_unittf:
|
||||
|
||||
+3
-2
@@ -24,8 +24,9 @@ class ChanMACDHistSet():
|
||||
def set_pre(self, pre_histset):
|
||||
self.pre = pre_histset
|
||||
def set_middle_klu(self, middle_klu):
|
||||
self.middle_klu = middle_klu
|
||||
self.middle_area = abs(middle_klu.macdhist)
|
||||
#self.middle_klu = middle_klu
|
||||
#self.middle_area = abs(middle_klu.macdhist)
|
||||
self.middle_klu = None
|
||||
def set_unittf_div(self, unittf_div):
|
||||
self.unittf_div = unittf_div
|
||||
def add_klu(self, klu):
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ class ChanMACDUnitTF():
|
||||
#if histset.peak_klu:
|
||||
#print("Unittf: ", self.start_klu.time, len(self.histset_list), histset.peak_klu.time)
|
||||
if self.peak_klu:
|
||||
if histset.peak_klu and histset.end_time:
|
||||
if histset.peak_klu:
|
||||
if abs(histset.peak_klu.macdhist) >= abs(self.peak_klu.macdhist):
|
||||
self.peak_klu = histset.peak_klu
|
||||
self.div_type = Chan_MACDUNITTF_DIV.UNDIV
|
||||
|
||||
+2
-1
@@ -1247,7 +1247,8 @@ def serialize_chan_macd_data(chan_macd_data, client_tz):
|
||||
serialized_data['klu_list'].append({
|
||||
'time': format_time_safely(getattr(klu, 'time', None), client_tz),
|
||||
'continue_div': bool(getattr(klu, 'continue_div', False)),
|
||||
'separate_div': bool(getattr(klu, 'separate_div', False))
|
||||
'separate_div': bool(getattr(klu, 'separate_div', False)),
|
||||
'near0_return': int(getattr(klu, 'near0_return', 0)) if getattr(klu, 'near0_return', 0) is not None else 0
|
||||
})
|
||||
except Exception as e:
|
||||
print(f"序列化klu出错: {e}")
|
||||
|
||||
@@ -3084,6 +3084,17 @@
|
||||
size: 0.6
|
||||
});
|
||||
}
|
||||
// near0_return > 0:在主图显示具体数值
|
||||
if (item.near0_return && Number(item.near0_return) > 0) {
|
||||
kluDivMarkers.push({
|
||||
time: ts,
|
||||
position: 'belowBar',
|
||||
color: '#8bc34a',
|
||||
shape: 'circle',
|
||||
text: `N${Number(item.near0_return)}`,
|
||||
size: 0.6
|
||||
});
|
||||
}
|
||||
});
|
||||
window.kluDivMarkers = kluDivMarkers;
|
||||
} catch (e) {
|
||||
@@ -5120,7 +5131,7 @@
|
||||
if (fx.fx_strength < 1.0) { // 降低阈值,让更多分型显示
|
||||
displayText = fx.fx_strength >= 0.8 ? '' : '' // 0.8以上显示点,0.8以下不显示文本
|
||||
}
|
||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("31", "").replace("41", "").replace("51", "");
|
||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("1", "").replace("2", "").replace("3", "").replace("41", "").replace("51", "");
|
||||
// 添加标记配置
|
||||
const markerConfig = {
|
||||
time: timestamp,
|
||||
@@ -5184,7 +5195,7 @@
|
||||
if (fx.fx_strength < 1.0) { // 降低阈值,让更多分型显示
|
||||
displayText = fx.fx_strength >= 1.5 ? '' : '' // 0.8以上显示点,0.8以下不显示文本
|
||||
}
|
||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("31", "").replace("41", "").replace("51", "");
|
||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("1", "").replace("2", "").replace("3", "").replace("41", "").replace("51", "");
|
||||
// 添加标记配置
|
||||
const markerConfig = {
|
||||
time: timestamp,
|
||||
@@ -5268,7 +5279,7 @@
|
||||
if (fx.fx_strength < 1.0){ // 调整小周期阈值
|
||||
displayText = fx.fx_strength >= 0.6 ? '' : '' // 0.6以上显示点
|
||||
}
|
||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("31", "").replace("41", "").replace("51", "");
|
||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("1", "").replace("2", "").replace("3", "").replace("41", "").replace("51", "");
|
||||
// 小周期分型标记配置
|
||||
const markerConfig = {
|
||||
time: timestamp,
|
||||
@@ -5324,7 +5335,7 @@
|
||||
if (fx.fx_strength < 2.0){ // 调整小周期阈值
|
||||
displayText = fx.fx_strength >= 1.5 ? '' : '' // 0.6以上显示点
|
||||
}
|
||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("31", "").replace("41", "").replace("51", "");
|
||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("1", "").replace("2", "").replace("3", "").replace("41", "").replace("51", "");
|
||||
// 小周期KLU分型标记配置
|
||||
const markerConfig = {
|
||||
time: timestamp,
|
||||
@@ -5369,7 +5380,6 @@
|
||||
const combinedMarkers = [
|
||||
...(window.mainFxMarkers || []),
|
||||
...allElementFxMarkers,
|
||||
...((typeof window.showUOnMain === 'undefined' || window.showUOnMain) ? (window.unittfMarkers || []) : []),
|
||||
...(window.kluDivMarkers || [])
|
||||
];
|
||||
if (combinedMarkers.length > 0) {
|
||||
@@ -5393,7 +5403,6 @@
|
||||
// 只设置主周期分型 + UnitTF 标记
|
||||
const onlyMainAndU = [
|
||||
...(window.mainFxMarkers || []),
|
||||
...((typeof window.showUOnMain === 'undefined' || window.showUOnMain) ? (window.unittfMarkers || []) : []),
|
||||
...(window.kluDivMarkers || [])
|
||||
];
|
||||
if (onlyMainAndU.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user