diff --git a/.DS_Store b/.DS_Store
index b4372df..29e0c04 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/ChanPY.py b/ChanPY.py
index b1727ab..0096f3c 100644
--- a/ChanPY.py
+++ b/ChanPY.py
@@ -1,7 +1,7 @@
import sys
import os
-sys.path.append(os.path.abspath("/Users/jack/Documents/GitHub/chan.py"))
-#sys.path.append(os.path.abspath("/Users/jack/Project/chan.py"))
+#sys.path.append(os.path.abspath("/Users/jack/Documents/GitHub/chan.py"))
+sys.path.append(os.path.abspath("/Users/jack/Project/chan.py"))
from Chan import CChan
from BuySellPoint.BS_Point import CBS_Point
from ChanConfig import CChanConfig
diff --git a/web/app.py b/web/app.py
index bf29c40..4d43f89 100644
--- a/web/app.py
+++ b/web/app.py
@@ -288,11 +288,11 @@ def add_indicators(df):
df['bb_middle'] = bb['middleband'].fillna(0)
df['bb_lower'] = bb['lowerband'].fillna(0)
bb30 = ta.BBANDS(df, timeperiod=41, nbdevup=2.3, nbdevdn=2.3, matype=0)
- bb30 = ta.BBANDS(df, timeperiod=20, nbdevup=2.0, nbdevdn=2.0, matype=0)
+ #bb30 = ta.BBANDS(df, timeperiod=20, nbdevup=2.0, nbdevdn=2.0, matype=0)
df['bbup30'] = bb30['upperband'].fillna(0)
df['bblow30'] = bb30['lowerband'].fillna(0)
bb302 = ta.BBANDS(df, timeperiod=41, nbdevup=2.0, nbdevdn=2.0, matype=0)
- bb302 = ta.BBANDS(df, timeperiod=20, nbdevup=2.0, nbdevdn=2.0, matype=0)
+ #bb302 = ta.BBANDS(df, timeperiod=20, nbdevup=2.0, nbdevdn=2.0, matype=0)
df['bbup302'] = bb302['upperband'].fillna(0)
df['bblow302'] = bb302['lowerband'].fillna(0)
# 计算次周期布林带 (14周期,2标准差)
diff --git a/web/templates/index.html b/web/templates/index.html
index d95d97c..d43e5d3 100644
--- a/web/templates/index.html
+++ b/web/templates/index.html
@@ -909,14 +909,14 @@
-
-
-
-
+
+
+
+
@@ -956,6 +956,10 @@
+
+
+
+
@@ -2899,7 +2903,7 @@
hasKlineData: !!currentData.kline_data,
isArray: Array.isArray(currentData.kline_data)
});
- if (showMacd && chanMacdChart && currentData.macd && currentData.kline_data && Array.isArray(currentData.kline_data)) {
+ if (showMacd && chanMacdChart && ((useElementPeriod && currentData.element_macd) || currentData.macd) && (useElementPeriod ? currentData.element_kline_data : currentData.kline_data)) {
console.log('✅ 开始创建 ChanMACD 系列');
// 创建ChanMACD线系列
const chanMacdLineSeries = chanMacdChart.addLineSeries({
@@ -2942,11 +2946,9 @@
},
});
- // 使用相同的MACD数据源
+ // 使用与主图一致的数据源(小周期开启时使用小周期MACD与K线)
const klineDataSource = useElementPeriod ? currentData.element_kline_data : currentData.kline_data;
- const macdDataSource = useElementPeriod ?
- (currentData.element_macd || currentData.macd) :
- currentData.macd;
+ const macdDataSource = useElementPeriod ? (currentData.element_macd || currentData.macd) : currentData.macd;
// 准备ChanMACD数据
const chanMacdData = [];
@@ -3019,32 +3021,36 @@
console.log('✅ ChanMACD图表系列已保存到tvWidget');
// 添加ChanMACD分析标注
- if (currentData.chan_macd) {
+ // 根据主/次周期开关与各自的“显示U”独立控制
+ const cm = useElementPeriod ? (currentData.element_chan_macd || currentData.chan_macd) : currentData.chan_macd;
+ const allowU = useElementPeriod ? (typeof window.showUOnElement === 'undefined' ? true : window.showUOnElement)
+ : (typeof window.showUOnMain === 'undefined' ? true : window.showUOnMain);
+ if (cm && allowU) {
console.log('添加ChanMACD分析标注:', {
- segListLength: currentData.chan_macd.seg_list ? currentData.chan_macd.seg_list.length : 0,
- unittfListLength: currentData.chan_macd.unittf_list ? currentData.chan_macd.unittf_list.length : 0,
- histsetListLength: currentData.chan_macd.histset_list ? currentData.chan_macd.histset_list.length : 0
+ segListLength: cm.seg_list ? cm.seg_list.length : 0,
+ unittfListLength: cm.unittf_list ? cm.unittf_list.length : 0,
+ histsetListLength: cm.histset_list ? cm.histset_list.length : 0
});
// 详细检查段数据
- if (currentData.chan_macd.seg_list && currentData.chan_macd.seg_list.length > 0) {
- console.log('段数据详情:', currentData.chan_macd.seg_list.slice(0, 3)); // 显示前3个段
+ if (cm.seg_list && cm.seg_list.length > 0) {
+ console.log('段数据详情:', cm.seg_list.slice(0, 3)); // 显示前3个段
} else {
console.log('⚠️ 段数据为空或不存在');
}
addAllChanMacdMarkers(
- currentData.chan_macd.seg_list || [],
- currentData.chan_macd.unittf_list || [],
- currentData.chan_macd.histset_list || [],
+ cm.seg_list || [],
+ cm.unittf_list || [],
+ cm.histset_list || [],
{
- high_position_list: currentData.chan_macd.high_position_list || [],
- high_empty_list: currentData.chan_macd.high_empty_list || [],
- low_position_list: currentData.chan_macd.low_position_list || [],
- low_empty_list: currentData.chan_macd.low_empty_list || [],
- return_zero_list: currentData.chan_macd.return_zero_list || [],
- cross0_up_list: currentData.chan_macd.cross0_up_list || [],
- cross0_down_list: currentData.chan_macd.cross0_down_list || []
+ high_position_list: cm.high_position_list || [],
+ high_empty_list: cm.high_empty_list || [],
+ low_position_list: cm.low_position_list || [],
+ low_empty_list: cm.low_empty_list || [],
+ return_zero_list: cm.return_zero_list || [],
+ cross0_up_list: cm.cross0_up_list || [],
+ cross0_down_list: cm.cross0_down_list || []
}
);
} else {
@@ -5694,7 +5700,7 @@
}
// 更新 ChanMACD 数据与自定义标注
- if (tvWidget.series.chanMacdLineSeries && currentData.macd && currentData.kline_data && Array.isArray(currentData.kline_data)) {
+ if (tvWidget.series.chanMacdLineSeries && ((useElementPeriod && currentData.element_macd) || currentData.macd) && (useElementPeriod ? currentData.element_kline_data : currentData.kline_data)) {
const klineDataSource = useElementPeriod ? currentData.element_kline_data : currentData.kline_data;
const macdDataSource = useElementPeriod ? (currentData.element_macd || currentData.macd) : currentData.macd;
if (macdDataSource && macdDataSource.macd && macdDataSource.signal && macdDataSource.histogram) {
@@ -5719,19 +5725,20 @@
// 重新应用自定义标注(段/UnitTF/HistSet/状态点)
try {
if (typeof clearChanMacdMarkers === 'function') clearChanMacdMarkers();
- if (currentData.chan_macd) {
+ const cm = useElementPeriod ? (currentData.element_chan_macd || currentData.chan_macd) : currentData.chan_macd;
+ if (cm) {
addAllChanMacdMarkers(
- currentData.chan_macd.seg_list || [],
- currentData.chan_macd.unittf_list || [],
- currentData.chan_macd.histset_list || [],
+ cm.seg_list || [],
+ cm.unittf_list || [],
+ cm.histset_list || [],
{
- high_position_list: currentData.chan_macd.high_position_list || [],
- high_empty_list: currentData.chan_macd.high_empty_list || [],
- low_position_list: currentData.chan_macd.low_position_list || [],
- low_empty_list: currentData.chan_macd.low_empty_list || [],
- return_zero_list: currentData.chan_macd.return_zero_list || [],
- cross0_up_list: currentData.chan_macd.cross0_up_list || [],
- cross0_down_list: currentData.chan_macd.cross0_down_list || []
+ high_position_list: cm.high_position_list || [],
+ high_empty_list: cm.high_empty_list || [],
+ low_position_list: cm.low_position_list || [],
+ low_empty_list: cm.low_empty_list || [],
+ return_zero_list: cm.return_zero_list || [],
+ cross0_up_list: cm.cross0_up_list || [],
+ cross0_down_list: cm.cross0_down_list || []
}
);
}
@@ -6020,6 +6027,20 @@
function setupTooltip(mainChart, buyMarkers = [], sellMarkers = [], mainChartContainer, volumeChartContainer, atrChartContainer, macdChartContainer, chanMacdChartContainer, volumeChart, atrChart, macdChart, chanMacdChart, showMacd) {
// 调试变量
window.debugMode = true;
+ // 初始化 U 显示状态(主/次周期分开控制)
+ const isShowUMain = $('#toggleUOnMain').is(':checked');
+ const isShowUElement = $('#toggleUOnElement').is(':checked');
+ window.showUOnMain = isShowUMain;
+ window.showUOnElement = isShowUElement;
+ if (!isShowUMain && !isShowUElement) {
+ // 隐藏时清空子图上的 U 标记
+ if (tvWidget.series && tvWidget.series.chanMacdLineSeries) {
+ try { tvWidget.series.chanMacdLineSeries.setMarkers([]); } catch (e) {}
+ }
+ if (tvWidget.series && tvWidget.series.chanMacdSignalSeries) {
+ try { tvWidget.series.chanMacdSignalSeries.setMarkers([]); } catch (e) {}
+ }
+ }
// 添加买卖点悬浮提示元素
const tooltipElement = document.createElement('div');
@@ -7460,6 +7481,12 @@
window.showUOnMain = $('#toggleUOnMain').is(':checked');
refreshChartOnly();
});
+
+ // 次周期 U 显示开关
+ $('#toggleUOnElement').change(function() {
+ window.showUOnElement = $('#toggleUOnElement').is(':checked');
+ refreshChartOnly();
+ });
// 在控制台输出当前显示状态
console.log('当前显示状态:', {