MACD使用标准参数
This commit is contained in:
@@ -63,9 +63,9 @@ class ChanLun_BTC_K(IStrategy):
|
||||
timeframe = '5m'
|
||||
|
||||
# 指标参数
|
||||
macd_fast = 12
|
||||
macd_slow = 26
|
||||
macd_signal = 9
|
||||
macd_fast = 24
|
||||
macd_slow = 52
|
||||
macd_signal = 18
|
||||
ema_short = 24
|
||||
ema_long = 52
|
||||
|
||||
@@ -120,7 +120,7 @@ class ChanLun_BTC_K(IStrategy):
|
||||
# 金叉/死叉
|
||||
df_resampled[f'macd_cross_up_{suffix}'] = (df_resampled[f'macd_{suffix}'] > df_resampled[f'macdsignal_{suffix}']) & (df_resampled[f'macd_{suffix}'].shift(1) <= df_resampled[f'macdsignal_{suffix}'].shift(1))
|
||||
df_resampled[f'macd_cross_down_{suffix}'] = (df_resampled[f'macd_{suffix}'] < df_resampled[f'macdsignal_{suffix}']) & (df_resampled[f'macd_{suffix}'].shift(1) >= df_resampled[f'macdsignal_{suffix}'].shift(1))
|
||||
return df_resampled[[
|
||||
cols = [
|
||||
'date',
|
||||
'close',
|
||||
f'macd_{suffix}', f'macdsignal_{suffix}', f'macdhist_{suffix}',
|
||||
@@ -128,7 +128,9 @@ class ChanLun_BTC_K(IStrategy):
|
||||
f'atr_{suffix}', f'atr_pct_{suffix}',
|
||||
f'above_zero_{suffix}', f'below_zero_{suffix}', f'near_zero_{suffix}', f'hist_increasing_{suffix}', f'hist_decreasing_{suffix}',
|
||||
f'high_position_{suffix}', f'macd_cross_up_{suffix}', f'macd_cross_down_{suffix}'
|
||||
]]
|
||||
]
|
||||
# 确保返回独立副本,避免下游在 resampled_merge 内部触发 SettingWithCopyWarning
|
||||
return df_resampled.loc[:, cols].copy()
|
||||
|
||||
for suf, minutes in intervals.items():
|
||||
df_res = resample_to_interval(dataframe, minutes)
|
||||
|
||||
Reference in New Issue
Block a user