唐安奇通道和布林通道差不多,都是判断超买和超卖的工具,我还是喜欢rsi强度来判断超买和超卖,不过这二者可以相互印证一下。这里简单的画一下图,介绍一下。
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 19 11:23:13 2017
@author: Administrator
"""
import tushare as ts
import pandas as pd
import matplotlib.pyplot as plt
tsyl_data=ts.get_k_data('000001')
tsyl_data.index=tsyl_data.iloc[:,0]
tsyl_data.index=pd.to_datetime(tsyl_data.index,format='%Y-%m-%d')
#提取收盘价、最低价、最高价
my_close=tsyl_data.close
my_low=tsyl_data.low
my_high=tsyl_data.high
#设定上下通道初始值
upboundDC=pd.Series(0.0,index=my_close.index)
downboundDC=pd.Series(0.0,index=my_close.index)
midboundDC=pd.Series(0.0,index=my_close.index)
#求唐奇安通道
for i in range(20,len(tsyl_data.close)):
upboundDC[i]=max(my_high[(i-20):i])
downboundDC[i]=min(my_low[(i-20):i])
midboundDC[i]=0.5*(upboundDC[i]+downboundDC[i])
upboundDC=upboundDC[20:]
downboundDC=downboundDC[20:]
midboundDC=midboundDC[20:]
#绘图
plt.rcParams['font.sans-serif']=['SimHei']
plt.plot(my_close['2016'],label="close",color='k')
plt.plot(upboundDC['2016'],label="up",color='b',linestyle='dashed')
plt.plot(downboundDC['2016'],label="down",color='r',linestyle='-')
plt.plot(midboundDC['2016'],label="mid",color='b',linestyle='dashed')
plt.title("唐奇安通道")
plt.legend()
可以从图里看到,大部分情况股价都是在通道之中,所以这个指标也只是参考一下,并不是很好判断趋势。趋势的话,海龟交易法是用来判断趋势的,有兴趣的可以去看看。