修改默认参数

This commit is contained in:
jackyu66git
2025-11-22 16:51:12 +08:00
parent 3c033df1dc
commit fb88ae23f4
+42 -17
View File
@@ -5871,37 +5871,62 @@
} catch (e) {}
};
// 初始化默认EMA配置(仅在首次初始化时)
// 初始化默认均线/布林带配置(仅在首次初始化时)
if (!hasInitializedDefaultMAs && movingAverages.length === 0) {
console.log('初始化默认EMA指标');
console.log('初始化默认均线与布林带指标');
// 添加默认EMA配置
const defaultEMAs = [
{ type: 'EMA', length: 6, color: '#FF0000', name: 'EMA6' }, // 红色
{ type: 'EMA', length: 13, color: '#0000FF', name: 'EMA13' }, // 蓝色
{ type: 'EMA', length: 24, color: '#008000', name: 'EMA24' }, // 深绿色
{ type: 'EMA', length: 52, color: '#800080', name: 'EMA52' } // 紫色
if (typeof maIdCounter !== 'number' || !Number.isFinite(maIdCounter)) {
maIdCounter = 0;
}
if (typeof bbIdCounter !== 'number' || !Number.isFinite(bbIdCounter)) {
bbIdCounter = 0;
}
const defaultMAs = [
{ type: 'EMA', length: 52, color: '#800080', name: 'EMA52' }, // 紫色
{ type: 'EMA', length: 24, color: '#008000', name: 'EMA24' }, // 深绿色
{ type: 'SMA', length: 30, color: '#FF8C00', name: 'SMA30' }, // 橙色
{ type: 'SMA', length: 250, color: '#1E90FF', name: 'SMA250' } // 蓝色
];
defaultEMAs.forEach(ema => {
defaultMAs.forEach(ma => {
const config = {
id: ++maIdCounter,
type: ema.type,
length: ema.length,
type: ma.type,
length: ma.length,
source: 'close',
smoothType: 'none',
smoothLength: 3,
lineWidth: 1, // 1px线宽
lineStyle: 0, // 实线
color: ema.color,
visible: (ema.length === 24 || ema.length === 52)
lineWidth: 1, // 1px线宽
lineStyle: 0, // 实线
color: ma.color,
visible: true
};
movingAverages.push(config);
console.log(`添加默认${ema.name}:`, ema.color);
console.log(`添加默认${ma.name}:`, ma.color);
});
console.log('默认EMA配置完成,共添加', movingAverages.length, '个指标');
if (bollingerBands.length === 0) {
const defaultBB = {
id: ++bbIdCounter,
type: 'Bollinger Bands',
length: 20,
upperMultiplier: 2,
lowerMultiplier: 2,
source: 'close',
lineWidth: 2,
lineStyle: 0,
upperColor: '#ff6b6b',
middleColor: '#667eea',
lowerColor: '#4ecdc4',
visible: true
};
bollingerBands.push(defaultBB);
console.log('添加默认布林带: BB(20, 2, 2)');
}
console.log('默认指标配置完成,当前均线数量', movingAverages.length, '布林带数量', bollingerBands.length);
hasInitializedDefaultMAs = true;
}