添加动能理论chanmacd,顶底分型5隐形形态
This commit is contained in:
@@ -919,7 +919,7 @@
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" id="showMacd" checked>
|
||||
<label class="form-check-label" for="showMacd">MACD</label>
|
||||
<label class="form-check-label" for="showMacd">ChanMACD</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex align-items-center mt-2">
|
||||
@@ -2160,6 +2160,9 @@
|
||||
if (tvWidget.macdChart) {
|
||||
tvWidget.macdChart.timeScale().setVisibleLogicalRange(logicalRange);
|
||||
}
|
||||
if (tvWidget.chanMacdChart) {
|
||||
tvWidget.chanMacdChart.timeScale().setVisibleLogicalRange(logicalRange);
|
||||
}
|
||||
} else if (visibleRange) {
|
||||
// 如果没有逻辑范围,使用时间戳范围
|
||||
tvWidget.mainChart.timeScale().setVisibleRange(visibleRange);
|
||||
@@ -2477,6 +2480,16 @@
|
||||
chanMacdChartContainer.style.right = '0';
|
||||
chanMacdChartContainer.style.borderTop = '1px solid #e0e0e0';
|
||||
chanMacdChartContainer.style.zIndex = '10';
|
||||
// 水印:便于区分是新的 ChanMACD 子图
|
||||
const chanMacdWatermark = document.createElement('div');
|
||||
chanMacdWatermark.textContent = 'ChanMACD';
|
||||
chanMacdWatermark.style.position = 'absolute';
|
||||
chanMacdWatermark.style.top = '4px';
|
||||
chanMacdWatermark.style.left = '8px';
|
||||
chanMacdWatermark.style.fontSize = '11px';
|
||||
chanMacdWatermark.style.color = '#888';
|
||||
chanMacdWatermark.style.pointerEvents = 'none';
|
||||
chanMacdChartContainer.appendChild(chanMacdWatermark);
|
||||
|
||||
// 成交量位于 ChanMACD 之下
|
||||
volumeChartContainer.style.top = '70%';
|
||||
@@ -2887,11 +2900,12 @@
|
||||
isArray: Array.isArray(currentData.kline_data)
|
||||
});
|
||||
if (showMacd && chanMacdChart && currentData.macd && currentData.kline_data && Array.isArray(currentData.kline_data)) {
|
||||
console.log('✅ 开始创建 ChanMACD 系列');
|
||||
// 创建ChanMACD线系列
|
||||
const chanMacdLineSeries = chanMacdChart.addLineSeries({
|
||||
color: '#2962FF',
|
||||
lineWidth: 1,
|
||||
title: 'MACD',
|
||||
title: 'ChanMACD',
|
||||
lastValueVisible: false,
|
||||
priceLineVisible: false,
|
||||
});
|
||||
@@ -2900,7 +2914,7 @@
|
||||
const chanMacdSignalSeries = chanMacdChart.addLineSeries({
|
||||
color: '#FF6B6B',
|
||||
lineWidth: 1,
|
||||
title: 'Signal',
|
||||
title: 'ChanSignal',
|
||||
lastValueVisible: false,
|
||||
priceLineVisible: false,
|
||||
});
|
||||
@@ -2908,7 +2922,7 @@
|
||||
// 创建ChanMACD柱状图系列
|
||||
const chanMacdHistSeries = chanMacdChart.addHistogramSeries({
|
||||
color: '#26a69a',
|
||||
title: 'Histogram',
|
||||
title: 'ChanHistogram',
|
||||
priceFormat: {
|
||||
type: 'price',
|
||||
precision: 4,
|
||||
@@ -5477,6 +5491,9 @@
|
||||
if (showMacd && macdChart) {
|
||||
macdChart.timeScale().setVisibleRange(visibleRange);
|
||||
}
|
||||
if (showMacd && chanMacdChart) {
|
||||
chanMacdChart.timeScale().setVisibleRange(visibleRange);
|
||||
}
|
||||
|
||||
console.log('🔧 最终时间轴对齐完成');
|
||||
}
|
||||
@@ -5676,6 +5693,53 @@
|
||||
tvWidget.series.histogramSeries.setData(histogramData);
|
||||
}
|
||||
|
||||
// 更新 ChanMACD 数据与自定义标注
|
||||
if (tvWidget.series.chanMacdLineSeries && currentData.macd && currentData.kline_data && Array.isArray(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) {
|
||||
const chanMacdData = [];
|
||||
const chanSignalData = [];
|
||||
const chanHistData = [];
|
||||
for (let i = 0; i < klineDataSource.length; i++) {
|
||||
const kline = klineDataSource[i];
|
||||
if (kline && kline.date && i < macdDataSource.macd.length && macdDataSource.macd[i] !== null && macdDataSource.macd[i] !== undefined) {
|
||||
const timestamp = Math.floor(new Date(kline.date).getTime() / 1000);
|
||||
chanMacdData.push({ time: timestamp, value: macdDataSource.macd[i] });
|
||||
chanSignalData.push({ time: timestamp, value: macdDataSource.signal[i] });
|
||||
chanHistData.push({ time: timestamp, value: macdDataSource.histogram[i], color: macdDataSource.histogram[i] >= 0 ? 'rgba(220, 53, 69, 0.5)' : 'rgba(40, 167, 69, 0.5)' });
|
||||
}
|
||||
}
|
||||
if (chanMacdData.length > 0) {
|
||||
tvWidget.series.chanMacdLineSeries.setData(chanMacdData);
|
||||
tvWidget.series.chanMacdSignalSeries.setData(chanSignalData);
|
||||
tvWidget.series.chanMacdHistSeries.setData(chanHistData);
|
||||
}
|
||||
}
|
||||
// 重新应用自定义标注(段/UnitTF/HistSet/状态点)
|
||||
try {
|
||||
if (typeof clearChanMacdMarkers === 'function') clearChanMacdMarkers();
|
||||
if (currentData.chan_macd) {
|
||||
addAllChanMacdMarkers(
|
||||
currentData.chan_macd.seg_list || [],
|
||||
currentData.chan_macd.unittf_list || [],
|
||||
currentData.chan_macd.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 || []
|
||||
}
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('更新ChanMACD标注失败:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 重新显示笔、线段和中枢等图形
|
||||
redrawFractalElements();
|
||||
|
||||
@@ -7191,6 +7255,7 @@
|
||||
if (tvWidget.volumeChart) tvWidget.volumeChart.timeScale().setVisibleLogicalRange(logicalRange);
|
||||
if (tvWidget.atrChart) tvWidget.atrChart.timeScale().setVisibleLogicalRange(logicalRange);
|
||||
if (tvWidget.macdChart) tvWidget.macdChart.timeScale().setVisibleLogicalRange(logicalRange);
|
||||
if (tvWidget.chanMacdChart) tvWidget.chanMacdChart.timeScale().setVisibleLogicalRange(logicalRange);
|
||||
} else if (visibleRange) {
|
||||
tvWidget.mainChart.timeScale().setVisibleRange(visibleRange);
|
||||
if (tvWidget.volumeChart) tvWidget.volumeChart.timeScale().setVisibleRange(visibleRange);
|
||||
|
||||
Reference in New Issue
Block a user