继续bb
This commit is contained in:
@@ -66,9 +66,11 @@ class Chan_KLC_FX(Enum):
|
||||
TOP1 = auto()
|
||||
TOP2 = auto()
|
||||
TOP3 = auto()
|
||||
TOP4 = auto()
|
||||
BOTTOM1 = auto()
|
||||
BOTTOM2 = auto()
|
||||
BOTTOM3 = auto()
|
||||
BOTTOM4 = auto()
|
||||
UNKNOWN = auto()
|
||||
|
||||
|
||||
|
||||
+10
-4
@@ -50,6 +50,7 @@ class ChanKLC():
|
||||
def set_klc_fx_type(self, klc_fx_type):
|
||||
#print(self.start_time, klc_fx_type, self.get_feature_data()['klu_macd'], self.get_feature_data()['klu_macdhist'], self.get_feature_data()['klu_rsi'])
|
||||
self.klc_fx_type = klc_fx_type
|
||||
self.cal_bb_out()
|
||||
def add_klu(self, klu):
|
||||
self.klus.append(klu)
|
||||
def set_end_klu(self, klu):
|
||||
@@ -60,14 +61,19 @@ class ChanKLC():
|
||||
self.cal_shape_1()
|
||||
self.strength = self.cal_klc_strength()
|
||||
self.cal_bb_out()
|
||||
if self.pre:
|
||||
self.pre.cal_bb_out()
|
||||
#self.bb_out = True
|
||||
def cal_bb_out(self):
|
||||
for klu in self.klus:
|
||||
if self.high >= klu.bbup30 and klu.bbup30 > 0:
|
||||
if self.high >= klu.bbup302 and klu.bbup302 > 0 and (self.klc_fx_type == Chan_KLC_FX.TOP1 or self.klc_fx_type == Chan_KLC_FX.TOP2):
|
||||
self.bb_out = True
|
||||
break
|
||||
if self.low <= klu.bblow30 and klu.bblow30 > 0:
|
||||
if self.high >= klu.bbup30 and klu.bbup30 > 0:
|
||||
self.klc_fx_type = Chan_KLC_FX.TOP4
|
||||
if self.low <= klu.bblow302 and klu.bblow302 > 0 and (self.klc_fx_type == Chan_KLC_FX.BOTTOM1 or self.klc_fx_type == Chan_KLC_FX.BOTTOM2):
|
||||
self.bb_out = True
|
||||
break
|
||||
if self.low <= klu.bblow30 and klu.bblow30 > 0:
|
||||
self.klc_fx_type = Chan_KLC_FX.BOTTOM4
|
||||
def cal_indicators(self):
|
||||
for index in range(1, len(self.klus)):
|
||||
self.volume += self.klus[index].volume
|
||||
|
||||
@@ -26,6 +26,11 @@ class ChanKLU:
|
||||
self.bbp365 = 0
|
||||
self.bb120 = 0
|
||||
self.bb365 = 0
|
||||
self.bbp302 = 0
|
||||
self.bbup302 = 0
|
||||
self.bblow302 = 0
|
||||
self.bbup30 = 0
|
||||
self.bblow30 = 0
|
||||
# === 新增:K线类型 ===
|
||||
self.kline_type = None # K线类型:大阳线、大阴线、小阳线、小阴线
|
||||
|
||||
@@ -585,6 +590,9 @@ class ChanKLU:
|
||||
self.bbp30 = float(item['bbp30']) if 'bbp30' in item and item['bbp30'] else 0
|
||||
self.bbup30 = float(item['bbup30']) if 'bbup30' in item and item['bbup30'] else 0
|
||||
self.bblow30 = float(item['bblow30']) if 'bblow30' in item and item['bblow30'] else 0
|
||||
self.bbp302 = float(item['bbp302']) if 'bbp302' in item and item['bbp302'] else 0
|
||||
self.bbup302 = float(item['bbup302']) if 'bbup302' in item and item['bbup302'] else 0
|
||||
self.bblow302 = float(item['bblow302']) if 'bblow302' in item and item['bblow302'] else 0
|
||||
self.bbup120 = float(item['bbup120']) if 'bbup120' in item and item['bbup120'] else 0
|
||||
self.bblow120 = float(item['bblow120']) if 'bblow120' in item and item['bblow120'] else 0
|
||||
self.bbup365 = float(item['bbup365']) if 'bbup365' in item and item['bbup365'] else 0
|
||||
|
||||
@@ -156,11 +156,13 @@ class ChanLun_BTC_30(IStrategy):
|
||||
bb365 = ta.BBANDS(df, timeperiod=365, nbdevup=3.0, nbdevdn=3.0, matype=0)
|
||||
bb120 = ta.BBANDS(df, timeperiod=120, nbdevup=3.0, nbdevdn=3.0, matype=0)
|
||||
bb30 = ta.BBANDS(df, timeperiod=90, nbdevup=3.0, nbdevdn=3.0, matype=0)
|
||||
bb302 = ta.BBANDS(df, timeperiod=90, nbdevup=2.0, nbdevdn=2.0, matype=0)
|
||||
# 手动计算布林带 %B 指标 (BBP)
|
||||
# %B = (Price - Lower Band) / (Upper Band - Lower Band)
|
||||
bbp365 = (df['close'] - bb365['lowerband']) / (bb365['upperband'] - bb365['lowerband'])
|
||||
bbp120 = (df['close'] - bb120['lowerband']) / (bb120['upperband'] - bb120['lowerband'])
|
||||
bbp30 = (df['close'] - bb30['lowerband']) / (bb30['upperband'] - bb30['lowerband'])
|
||||
bbp302 = (df['close'] - bb302['lowerband']) / (bb302['upperband'] - bb302['lowerband'])
|
||||
df['bbup365'] = bb365['upperband']
|
||||
df['bblow365'] = bb365['lowerband']
|
||||
df['bbp365'] = bbp365
|
||||
@@ -170,6 +172,9 @@ class ChanLun_BTC_30(IStrategy):
|
||||
df['bbup30'] = bb30['upperband']
|
||||
df['bblow30'] = bb30['lowerband']
|
||||
df['bbp30'] = bbp30
|
||||
df['bbup302'] = bb302['upperband']
|
||||
df['bblow302'] = bb302['lowerband']
|
||||
df['bbp302'] = bbp302
|
||||
df['macd'] = macd['macd']
|
||||
df['macdsignal'] = macd['macdsignal']
|
||||
df['macdhist'] = macd['macdhist']
|
||||
|
||||
@@ -277,6 +277,9 @@ def add_indicators(df):
|
||||
bb30 = ta.BBANDS(df, timeperiod=90, nbdevup=3.0, nbdevdn=3.0, matype=0)
|
||||
df['bbup30'] = bb30['upperband'].fillna(0)
|
||||
df['bblow30'] = bb30['lowerband'].fillna(0)
|
||||
bb302 = ta.BBANDS(df, timeperiod=90, nbdevup=2.0, nbdevdn=2.0, matype=0)
|
||||
df['bbup302'] = bb302['upperband'].fillna(0)
|
||||
df['bblow302'] = bb302['lowerband'].fillna(0)
|
||||
# 计算次周期布林带 (14周期,2标准差)
|
||||
bb_element = ta.BBANDS(df, timeperiod=14, nbdevup=2.0, nbdevdn=2.0, matype=0)
|
||||
df['element_bb_upper'] = bb_element['upperband'].fillna(0)
|
||||
|
||||
@@ -3913,7 +3913,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("3", "");
|
||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("31", "");
|
||||
// 添加标记配置
|
||||
const markerConfig = {
|
||||
time: timestamp,
|
||||
@@ -3977,7 +3977,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("1", "").replace("2", "").replace("3", "");
|
||||
// 添加标记配置
|
||||
const markerConfig = {
|
||||
time: timestamp,
|
||||
@@ -4062,7 +4062,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("3", "");
|
||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("31", "");
|
||||
// 小周期分型标记配置
|
||||
const markerConfig = {
|
||||
time: timestamp,
|
||||
@@ -4118,7 +4118,7 @@
|
||||
if (fx.fx_strength < 2.0){ // 调整小周期阈值
|
||||
displayText = fx.fx_strength >= 1.5 ? '' : '' // 0.6以上显示点
|
||||
}
|
||||
|
||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("1", "").replace("2", "").replace("3", "");
|
||||
// 小周期KLU分型标记配置
|
||||
const markerConfig = {
|
||||
time: timestamp,
|
||||
@@ -7471,7 +7471,7 @@
|
||||
<div class="indicator-item" data-indicator-type="bb" data-indicator-id="${bb.id}" style="${itemStyle}">
|
||||
<div class="indicator-info">
|
||||
<div class="indicator-color-indicator" style="${colorIndicatorStyle}"></div>
|
||||
<span class="indicator-label">${bb.type}(${bb.length}, ${bb.upperMultiplier || 2}, ${bb.lowerMultiplier || 2})${styleText}</span>
|
||||
<span class="indicator-label">BB(${bb.length}, ${bb.upperMultiplier || 2}, ${bb.lowerMultiplier || 2})${styleText}</span>
|
||||
<span class="indicator-value">${bb.visible ? latestValue : '--'}</span>
|
||||
</div>
|
||||
<div class="indicator-actions">
|
||||
@@ -8149,7 +8149,7 @@
|
||||
color: bbConfig.upperColor,
|
||||
lineWidth: bbConfig.lineWidth || 2,
|
||||
lineStyle: bbConfig.lineStyle || 0, // 0=实线, 1=点线, 2=虚线, 3=大虚线
|
||||
title: `${bbConfig.type}(${bbConfig.length}, ${bbConfig.upperMultiplier}, ${bbConfig.lowerMultiplier}) Upper`,
|
||||
title: `BB(${bbConfig.length}, ${bbConfig.upperMultiplier}, ${bbConfig.lowerMultiplier}) Upper`,
|
||||
lastValueVisible: false,
|
||||
priceLineVisible: false,
|
||||
crosshairMarkerVisible: true,
|
||||
@@ -8159,7 +8159,7 @@
|
||||
color: bbConfig.middleColor,
|
||||
lineWidth: bbConfig.lineWidth || 2,
|
||||
lineStyle: bbConfig.lineStyle || 0, // 0=实线, 1=点线, 2=虚线, 3=大虚线
|
||||
title: `${bbConfig.type}(${bbConfig.length}, ${bbConfig.upperMultiplier}, ${bbConfig.lowerMultiplier}) Middle`,
|
||||
title: `BB(${bbConfig.length}, ${bbConfig.upperMultiplier}, ${bbConfig.lowerMultiplier}) Middle`,
|
||||
lastValueVisible: false,
|
||||
priceLineVisible: false,
|
||||
crosshairMarkerVisible: true,
|
||||
@@ -8169,7 +8169,7 @@
|
||||
color: bbConfig.lowerColor,
|
||||
lineWidth: bbConfig.lineWidth || 2,
|
||||
lineStyle: bbConfig.lineStyle || 0, // 0=实线, 1=点线, 2=虚线, 3=大虚线
|
||||
title: `${bbConfig.type}(${bbConfig.length}, ${bbConfig.upperMultiplier}, ${bbConfig.lowerMultiplier}) Lower`,
|
||||
title: `BB(${bbConfig.length}, ${bbConfig.upperMultiplier}, ${bbConfig.lowerMultiplier}) Lower`,
|
||||
lastValueVisible: false,
|
||||
priceLineVisible: false,
|
||||
crosshairMarkerVisible: true,
|
||||
@@ -8466,7 +8466,7 @@
|
||||
<div class="bb-config-group">
|
||||
<label class="bb-config-label">类型</label>
|
||||
<select id="bbType" class="bb-config-select">
|
||||
<option value="Bollinger Bands">Bollinger Bands</option>
|
||||
<option value="Bollinger Bands">BB</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="bb-config-group">
|
||||
|
||||
Reference in New Issue
Block a user