修改默认参数

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) {} } catch (e) {}
}; };
// 初始化默认EMA配置(仅在首次初始化时) // 初始化默认均线/布林带配置(仅在首次初始化时)
if (!hasInitializedDefaultMAs && movingAverages.length === 0) { if (!hasInitializedDefaultMAs && movingAverages.length === 0) {
console.log('初始化默认EMA指标'); console.log('初始化默认均线与布林带指标');
// 添加默认EMA配置 if (typeof maIdCounter !== 'number' || !Number.isFinite(maIdCounter)) {
const defaultEMAs = [ maIdCounter = 0;
{ type: 'EMA', length: 6, color: '#FF0000', name: 'EMA6' }, // 红色 }
{ type: 'EMA', length: 13, color: '#0000FF', name: 'EMA13' }, // 蓝色 if (typeof bbIdCounter !== 'number' || !Number.isFinite(bbIdCounter)) {
{ type: 'EMA', length: 24, color: '#008000', name: 'EMA24' }, // 深绿色 bbIdCounter = 0;
{ type: 'EMA', length: 52, color: '#800080', name: 'EMA52' } // 紫色 }
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 = { const config = {
id: ++maIdCounter, id: ++maIdCounter,
type: ema.type, type: ma.type,
length: ema.length, length: ma.length,
source: 'close', source: 'close',
smoothType: 'none', smoothType: 'none',
smoothLength: 3, smoothLength: 3,
lineWidth: 1, // 1px线宽 lineWidth: 1, // 1px线宽
lineStyle: 0, // 实线 lineStyle: 0, // 实线
color: ema.color, color: ma.color,
visible: (ema.length === 24 || ema.length === 52) visible: true
}; };
movingAverages.push(config); 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; hasInitializedDefaultMAs = true;
} }