From 9f8c51600e76f7a0b0d041743a25a1671fce1b02 Mon Sep 17 00:00:00 2001 From: aszerW Date: Sun, 19 Oct 2025 10:22:41 +0800 Subject: [PATCH] =?UTF-8?q?CCI=E6=98=BE=E7=A4=BAperiod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chart.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/chart.py b/chart.py index 80a1bd8..573aab2 100644 --- a/chart.py +++ b/chart.py @@ -41,7 +41,7 @@ def add_ema(df, chart, period: int = 50): def add_cci(df, chart, period: int = 14, height: float = 0.1, position: str = "bottom"): cci = ta.CCI(df["high"], df["low"], df["close"], timeperiod=period) - df["CCI"] = cci + df[f"CCI_{period}"] = cci cci_chart = chart.create_subchart( position=position, width=1, height=height, sync=True ) @@ -49,8 +49,8 @@ def add_cci(df, chart, period: int = 14, height: float = 0.1, position: str = "b visible=True, font_size=14, color="#FFFFFF", font_family="Times New Roman" ) cci_chart.time_scale(visible=False) - cci_line = cci_chart.create_line(name="CCI", color="#FF0000", width=2) - cci_line.set(df[["time", "CCI"]]) + cci_line = cci_chart.create_line(name=f"CCI_{period}", color="#FF0000", width=2) + cci_line.set(df[["time", f"CCI_{period}"]]) df = df[["time"]].copy() df["h"] = 100 df["l"] = -100 @@ -149,7 +149,7 @@ def add_TD(df, chart): TDs = df[["time", "TD"]].to_dict(orient="records") markers = [] for item in TDs: - if item["TD"] == 9: + if item["TD"] in [9, 13]: markers.append( { "time": item["time"].strftime("%Y-%m-%d"), @@ -159,7 +159,7 @@ def add_TD(df, chart): "text": f"{item['TD']}", } ) - elif item["TD"] == -9: + elif item["TD"] in [-9, -13]: markers.append( { "time": item["time"].strftime("%Y-%m-%d"), @@ -376,7 +376,7 @@ def plot_chart(df, symbol: str, name: str, timeframe: str): add_ema(df, chart, period=30) add_ema(df, chart, period=60) add_macd(df, chart) - add_cci(df, chart, period=26) + add_cci(df, chart, period=14) add_TD(df, chart) add_buy_sell_signal_markers(df, chart)