用代码实例解析python瀑布线指标-创新互联
小编这次要给大家分享的是用代码实例解析python瀑布线指标,文章内容丰富,感兴趣的小伙伴可以来了解一下,希望大家阅读完这篇文章之后能够有所收获。

我就废话不多说了,大家还是直接看代码吧!
# -*- coding: utf-8 -*-
"""
Created on Tue May 23 08:57:02 2017
@author: yunjinqi
E-mail:yunjinqi@qq.com
Differentiate yourself in the world from anyone else.
"""
import pandas as pd
import numpy as np
import datetime
import time
#获取数据
df=pd.read_csv('C:/Users/HXWD/Desktop/000001.csv',encoding='gbk')
df.columns=['date','code','name','close','high','low','open','preclose',
'change','change_per','volume','amt']
df=df[['date','open','high','low','close','volume','amt']]
df.head()
def get_EMA(df,N):
for i in range(len(df)):
if i==0:
df.ix[i,'ema']=df.ix[i,'close']
if i>0:
df.ix[i,'ema']=(2*df.ix[i-1,'close']+(N-1)*df.ix[i,'close'])/(N+1)
return df['ema']
def get_PBX(df):
df['a1']=(get_EMA(df,4)+df['close'].rolling(8).mean()+
df['close'].rolling(16).mean())/3
df['a2']=(get_EMA(df,6)+df['close'].rolling(12).mean()+
df['close'].rolling(24).mean())/3
df['a3']=(get_EMA(df,9)+df['close'].rolling(18).mean()+
df['close'].rolling(36).mean())/3
df['a4']=(get_EMA(df,13)+df['close'].rolling(26).mean()+
df['close'].rolling(52).mean())/3
df['a5']=(get_EMA(df,18)+df['close'].rolling(36).mean()+
df['close'].rolling(72).mean())/3
df['a6']=(get_EMA(df,24)+df['close'].rolling(48).mean()+
df['close'].rolling(96).mean())/3
return df
get_PBX(df)
df.tail()
'''
瀑布线
原理:均线类指标
用法:
瀑布线是趋势性指标,因其在运行的过程中,形态与瀑布极其相似,故得名为瀑布线。
瀑布线在低位粘合,短线瀑布线向上穿越长线瀑布线并向上发散,买入。
瀑布线在高位粘合,短线瀑布线向下穿越长线瀑布线并向下发散,卖出。
当长中短期瀑布线依次由下向上排列形成多头排列时,可持股。
当长中短期瀑布线依次由上向下排列形成空头排列时,应空仓。
''' 分享名称:用代码实例解析python瀑布线指标-创新互联
文章地址:http://www.scyingshan.cn/article/gheeg.html


咨询
建站咨询
