关于成交量均线指标的问题,我们总结了以下几点,给你解答:
成交量均线指标代码
STICKLINE(v
v
成交量均线指标
:param df:
:param n:
:return:
"""
vol_ma = pd.Series(df['volume'].rolling(n).mean(), name='vol_ma_' + str(n))
df = df.join(vol_ma)
return df
def get_vol_ema(df, n):
"""
计算成交量指数移动平均线
:param df:
:param n:
:return:
"""
vol_ema = pd.Series(df['volume'].ewm(span=n, min_periods=n).mean(), name='vol_ema_' + str(n))
df = df.join(vol_ema)
return df
def get_vol_dif(df, n):
"""
计算成交量差
:param df:
:param n:
:return:
"""
vol_dif = pd.Series(df['vol_ma_' + str(n)].diff(1), name='vol_dif_' + str(n))
df = df.join(vol_dif)
return df
def get_vol_dea(df, n):
"""
计算成交量差的指数移动平均线
:param df:
:param n:
:return:
"""
vol_dea = pd.Series(df['vol_dif_' + str(n)].ewm(span=n, min_periods=n).mean(), name='vol_dea_' + str(n))
df = df.join(vol_dea)
return df
def get_vol_macd(df, n):
"""
计算成交量的MACD
:param df:
:param n:
:return:
"""
vol_macd = pd.Series(df['vol_dif_' + str(n)] - df['vol_dea_' + str(n)], name='vol_macd_' + str(n))
df = df.join(vol_macd)
return df
def get_vol_macd_signal(df, n):
"""
计算成交量的MACD信号线
:param df:
:param n:
:return:
"""
vol_macd_signal = pd.Series(df['vol_macd_' + str(n)].ewm(span=n, min_periods=n).mean(), name='vol_macd_signal_' + str(n))
df = df.join(vol_macd_signal)
return df
def get_vol_macd_hist(df, n):
"""
计算成交量的MACD柱状图
:param df:
:param n:
:return:
"""
vol_macd_hist = pd.Series(df['vol_macd_' + str(n)] - df['vol_macd_signal_' + str(n)], name='vol_macd_hist_' + str(n))
df = df.join(vol_macd_hist)
return df
def get_vol_kdj(df, n):
"""
计算成交量的KDJ
:param df:
:param n:
:return:
"""
vol_kdj_k = pd.Series(pd.ewma(df['vol_dif_' + str(n)], span=n) * 3 - pd.ewma(df['vol_dea_' + str(n)], span=n) * 2,
name='vol_kdj_k_' + str(n))
vol_kdj_d = pd.Series(pd.ewma(vol_kdj_k, span=n), name='vol_kdj_d_' + str(n))
vol_kdj_j = pd.Series(3 * vol_kdj_k - 2 * vol_kdj_d, name='vol_kdj_j_' + str(n))
df = df.join(vol_kdj_k)
df = df.join(vol_kdj_d)
df = df.join(vol_kdj_j)
return df
def get_vol_rsi(df, n):
"""
计算成交量的RSI
:param df:
:param n:
:return:
"""
vol_up = df['vol_dif_' + str(n)].copy()
vol_up[vol_up < 0] = 0
vol_down = df['vol_dif_' + str(n)].copy()
vol_down[vol_down > 0] = 0
vol_rsi = pd.Series(pd.ewma(vol_up, span=n) / (pd.ewma(vol_up, span=n) - pd.ewma(vol_down, span=n)),
name='vol_rsi_' + str(n))
df = df.join(vol_rsi)
return df
def get_vol_obv(df):
"""
计算成交量的OBV
:param df:
:return:
"""
vol_obv = pd.Series(np.where(df['close'] > df['close'].shift(1), df['volume'],
np.where(df['close'] < df['close'].shift(1), -df['volume'], 0)).cumsum(),
name='vol_obv')
df = df.join(vol_obv)
return df
def get_vol_arbr(df, n):
"""
计算成交量的ARBR
:param df:
:param n:
:return:
"""
vol_arbr = pd.Series(pd.rolling_sum(df['vol_dif_' + str(n)], n) / pd.rolling_sum(df['vol_dif_' + str(n)].abs(), n),
name='vol_arbr_' + str(n))
df = df.join(vol_arbr)
return df
def get_vol_cr(df, n):
"""
计算成交量的CR
:param df:
:param n:
:return:
"""
vol_cr = pd.Series(pd.rolling_sum(df['vol_dif_' + str(n)].abs(), n) / pd.rolling_sum(df['volume'], n),
name='vol_cr_' + str(n))
df = df.join(vol_cr)
return df
def get_vol_dma(df, n, m):
"""
计算成交量的DMA
:param df:
:param n:
:param m:
:return:
"""
vol_dma = pd.Series(df['vol_ma_' + str(n)] - df['vol_ma_' + str(m)], name='vol_dma_' + str(n) + '_' + str(m))
df = df.join(vol_dma)
return df
def get_vol_trix(df, n):
"""
计算成交量的TRIX
:param df:
:param n:
:return:
"""
vol_ema1 = pd.Series(df['volume'].ewm(span=n, min_periods=n).mean(), name='vol_ema1_' + str(n))
vol_ema2 = pd.Series(vol_ema1.ewm(span=n, min_periods=n).mean(), name='vol_ema2
成交量均线指标公式
密码是OK_头价界意诉试言TDX
我的6.10版本已经密码了,给你源码:
M1 2 500 5
M2 2 500 10
VVOL:IF(CURRBARSCOUNT=1 AND PERIOD=5,VOL*240/FROMOPEN,DRAWNULL),NODRAW;
STICKLINE(CU来自RRBARSCOUNT石化角歌=1 AND PERIOD=5,VVOL,0,-1,-1),COLOR00C0C0;
VOLUME:VOL,VOLSTICK;
MAVOL1:MA(VOLUME,M1);
MAVOL2:MA(VOLUME,M2);