From da2ee3bb45751677c2d400bcb937677aa459732d Mon Sep 17 00:00:00 2001 From: jackyu66git Date: Sun, 6 Jul 2025 10:17:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bb=E5=8F=96=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/app.py | 2 +- web/templates/index.html | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/web/app.py b/web/app.py index 52d4485..d832c86 100644 --- a/web/app.py +++ b/web/app.py @@ -270,7 +270,7 @@ def add_indicators(df): df['rsi'] = ta.RSI(df, timeperiod=14) # 计算布林带 (当前周期 - 20周期,2标准差) - bb = ta.BBANDS(df, timeperiod=20, nbdevup=2.0, nbdevdn=2.0, matype=0) + bb = ta.BBANDS(df, timeperiod=365, nbdevup=3.0, nbdevdn=3.0, matype=0) df['bb_upper'] = bb['upperband'].fillna(0) df['bb_middle'] = bb['middleband'].fillna(0) df['bb_lower'] = bb['lowerband'].fillna(0) diff --git a/web/templates/index.html b/web/templates/index.html index cf3a01e..af531e0 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -3740,7 +3740,7 @@ if (fx.fx_strength < 1.0){ // 调整小周期阈值 displayText = fx.fx_strength >= 0.6 ? '' : '' // 0.6以上显示点 } - displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("1", "").replace("2", "").replace("30", ""); + displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("3", ""); // 小周期分型标记配置 const markerConfig = { time: timestamp, @@ -7003,12 +7003,13 @@ .reduce((sum, val) => sum + val, 0) / length; break; case 'EMA': - if (i === length - 1) { - // 第一个EMA值使用SMA - value = sourceData.slice(0, length) + const multiplier = 2 / (length + 1); + if (result.length === 0) { + // 第一个EMA值使用SMA作为种子值 + value = sourceData.slice(i - length + 1, i + 1) .reduce((sum, val) => sum + val, 0) / length; } else { - const multiplier = 2 / (length + 1); + // 后续EMA值使用标准公式 value = sourceData[i] * multiplier + result[result.length - 1].value * (1 - multiplier); } break; @@ -7052,11 +7053,13 @@ .reduce((sum, item) => sum + item.value, 0) / smoothLength; break; case 'EMA': - if (i === smoothLength - 1) { - value = maData.slice(0, smoothLength) + const multiplier = 2 / (smoothLength + 1); + if (result.length === 0) { + // 第一个EMA值使用SMA作为种子值 + value = maData.slice(i - smoothLength + 1, i + 1) .reduce((sum, item) => sum + item.value, 0) / smoothLength; } else { - const multiplier = 2 / (smoothLength + 1); + // 后续EMA值使用标准公式 value = maData[i].value * multiplier + result[result.length - 1].value * (1 - multiplier); } break;