#1
xh=False #判断趋势线形成信号
#此处已经比对完毕 true false true
condition=(
((df['close']-df['preclose'])>=0.9*df['atr'])&
(df['volume']>2*df['volume'].shift(1))&
(df['preclose']<df['close'].shift(-1))&
(df['close'].shift(-1)<df['close'])&
(0.4*df['volume']<=df['volume'].shift(-1))&
(df['volume'].shift(-1)<=0.6*df['volume'])
)
# result=df[condition]
# if len(result)==0:
# xh=True
#结果 是否有启动信号
#只取后30行
last_30_index=df.iloc[-30:].index
index_i=last_30_index[condition.loc[last_30_index]].tolist()
if len(index_i)==0:
xh=True
#2
#df 切割后的df可行吗?
# 其中df为最后一个趋势起点
# index_i[-1] #最后一个启动点
result=[]
result_index=[] #谷点位置
for i in range(index_i[-1]+1,len(df)-1):
# for i in range(1,len(df)-1):
a=df.iloc[i-1]
b=df.iloc[i]
c=df.iloc[i+1]
if (a['low']>b['low'])and(b['low']<c['low']):
result.append(b)
result_index.append(i)
result_df=pd.DataFrame(result)
xh=False #判断趋势线形成信号
if len(result_df)>2:
for i in range(0,len(result_df)-1):
if result_df.iloc[i]['low']>result_df.iloc[i+1]['low']:
xh=True
# 使用xh判断 是否趋势线形成
#3 没有循环判断
# 动态阻力线 支撑线 maxHigh minLow
# i行 即最后一个低点后到值 显示突破 目前没有动态创建 两个价格
# result_index[-1] 为后面最后一个谷底位置
resultx=[]
resultx_index=[]
zc=False
xh=False
for i in range(result_index[-1]+1,len(df)-1):
maxHigh=df.iloc[i-10:i]['high'].max()
minLow=df.iloc[i-10:i]['low'].min()
for j in range(i,len(df)-1):
#突破后阻力位转为支撑位
if (df.iloc[j]['close']>maxHigh) and (df.iloc[j]['volume']>=2*df.iloc[j-1]['volume']) and (df.iloc[j+1]['close']>maxHigh):
resultx.append(df.iloc[j])
result_index.append(j)
zc=maxHigh
for jj in range(j,len(df)):
#此处只记录突破位置
if zc:
if df.iloc[jj]['close']<zc:
xh=True
#破线 趋势结束
# 4 没有循环判断
# 成交量异常 放大
# resultx_index[-1]开始循环是否出现下面的形态
for ii in range(resultx_index[-1]+1,len(df)-1):
if df.iloc[ii]['volume']>2*df.iloc[ii-1]['volume']:
#锤子
if abs(df.iloc[ii]['close']-df.iloc[ii]['open'])*3<=(df.iloc[ii]['high']-df.iloc[ii]['low']) and (df.iloc[ii]['close']>df.iloc[ii]['low'])and (df.iloc[ii]['open']>df.iloc[ii]['low']):
xh=True
#黄昏星
if (df.iloc[ii-1]['close']>df.iloc[ii-1]['open'])and(df.iloc[ii+1]['close']<df.iloc[ii+1]['open']) and(abs(df.iloc[ii]['close']-df.iloc[ii]['open'])*3<=(df.iloc[ii]['high']-df.iloc[ii]['low']))and(df.iloc[ii]['high']>df.iloc[ii]['open'])and(df.iloc[ii]['high']>df.iloc[ii]['close']):
xh=True
#吞没
if (df.iloc[ii-1]['close']>df.iloc[ii-1]['open'])and(df.iloc[ii]['close']<df.iloc[ii]['open'])and(df.iloc[ii]['close']<df.iloc[ii-1]['open'])and(df.iloc[ii]['open']>df.iloc[ii-1]['close']):
xh=True
# 趋势结束
-
近期文章
近期评论
- admin 发表在《PDF文件分割图片》
- admin 发表在《混乱的五月即将告以段路》
- admin 发表在《系规看来不是300页那么简单》
- admin 发表在《系规看来不是300页那么简单》
- admin 发表在《扩展计划UserScript》
归档
- 2026 年 5 月
- 2026 年 4 月
- 2026 年 3 月
- 2026 年 2 月
- 2026 年 1 月
- 2025 年 12 月
- 2025 年 11 月
- 2025 年 10 月
- 2025 年 9 月
- 2025 年 8 月
- 2025 年 7 月
- 2025 年 6 月
- 2025 年 5 月
- 2025 年 4 月
- 2025 年 3 月
- 2025 年 2 月
- 2025 年 1 月
- 2024 年 12 月
- 2024 年 11 月
- 2024 年 10 月
- 2024 年 9 月
- 2024 年 8 月
- 2024 年 7 月
- 2024 年 6 月
- 2024 年 5 月
- 2024 年 4 月
- 2024 年 2 月
- 2024 年 1 月
- 2023 年 12 月
- 2023 年 11 月
- 2023 年 10 月
- 2022 年 10 月
- 2022 年 9 月
- 2022 年 8 月
- 2022 年 7 月
- 2022 年 6 月
- 2022 年 5 月
- 2022 年 4 月
- 2022 年 3 月
- 2022 年 1 月
- 2021 年 11 月
- 2021 年 10 月
- 2021 年 9 月
- 2021 年 4 月
- 2020 年 11 月
- 2020 年 10 月
- 2020 年 8 月
- 2020 年 5 月
- 2020 年 4 月
- 2020 年 1 月
- 2019 年 11 月
- 2019 年 7 月
- 2019 年 2 月
- 2019 年 1 月
- 2018 年 12 月
- 2018 年 11 月
- 2018 年 8 月
分类
友情链接
其他操作