添加默认均线

This commit is contained in:
jackyu66git
2025-07-02 01:14:28 +08:00
parent df8cd10473
commit b9486b3593
2 changed files with 66 additions and 15 deletions
+36
View File
@@ -3939,9 +3939,45 @@
tvWidget.macdChart = macdChart;
tvWidget.state.isInitialized = true;
// 初始化默认EMA配置(仅在首次初始化时)
if (movingAverages.length === 0) {
console.log('初始化默认EMA指标');
// 添加默认EMA配置
const defaultEMAs = [
{ type: 'EMA', length: 5, color: '#FF0000', name: 'EMA5' }, // 红色
{ type: 'EMA', length: 10, color: '#0000FF', name: 'EMA10' }, // 蓝色
{ type: 'EMA', length: 26, color: '#00FF00', name: 'EMA26' }, // 绿色
{ type: 'EMA', length: 52, color: '#800080', name: 'EMA52' } // 紫色
];
defaultEMAs.forEach(ema => {
const config = {
id: ++maIdCounter,
type: ema.type,
length: ema.length,
source: 'close',
smoothType: 'none',
smoothLength: 3,
lineWidth: 1, // 1px线宽
lineStyle: 0, // 实线
color: ema.color,
visible: true
};
movingAverages.push(config);
console.log(`添加默认${ema.name}:`, ema.color);
});
console.log('默认EMA配置完成,共添加', movingAverages.length, '个指标');
}
// 添加均线到图表
addMovingAveragesToChart(candles);
// 更新均线面板显示
updateMAPanel();
// 绑定同步事件
bindSyncEvents(mainChartContainer, volumeChartContainer, atrChartContainer, macdChartContainer, mainChart, volumeChart, atrChart, macdChart, showMacd);