通达信副图指标简介:
通达信六脉神剑指标可以帮助投资者从多个角度分析市场趋势和潜在的买卖点。金叉通常被视为买入信号,而死叉(指标线交叉向下)则可能是卖出信号。
指标效果图:
指标公式源码及源码注释:
副图指标:
DIFF:=EMA(CLOSE,8)-EMA(CLOSE,13);{计算MACD的DIFF值,即8日EMA与13日EMA的差}
DEA:=EMA(DIFF,5);{计算MACD的DEA值,即DIFF的5日EMA}
A1:=DIFF>DEA;{判断DIFF是否大于DEA}
MACD金叉:IF(A1,1,0),COLORRED;{如果DIFF大于DEA,标记为MACD金叉,颜色为红色}
RSV1:=(CLOSE-LLV(LOW,8))/(HHV(HIGH,8)-LLV(LOW,8))*100;{计算KDJ的RSV值}
K:=SMA(RSV1,3,1);{计算KDJ的K值,即RSV的3日SMA}
D:=SMA(K,3,1);{计算KDJ的D值,即K的3日SMA}
DRAWICON(K>D,2,1);{如果K大于D,绘制向上箭头图标}
DRAWICON(K<D,2,2);{如果K小于D,绘制向下箭头图标}
DRAWTEXT(ISLASTBAR=1,2,'.KDJ'),COLORFFFFFF;{在最后一个周期绘制KDJ文字,颜色为白色}
A2:=K>D;{判断K是否大于D}
KDJ金叉:IF(A2,2,0),COLORRED;{如果K大于D,标记为KDJ金叉,颜色为红色}
LC:=REF(CLOSE,1);{计算前一日收盘价}
RSI1:=(SMA(MAX(CLOSE-LC,0),5,1))/(SMA(ABS(CLOSE-LC),5,1))*100;{计算5日RSI值}
RSI2:=(SMA(MAX(CLOSE-LC,0),13,1))/(SMA(ABS(CLOSE-LC),13,1))*100;{计算13日RSI值}
DRAWICON(RSI1>RSI2,3,1);{如果5日RSI大于13日RSI,绘制向上箭头图标}
DRAWICON(RSI1<RSI2,3,2);{如果5日RSI小于13日RSI,绘制向下箭头图标}
DRAWTEXT(ISLASTBAR=1,3,'.RSI'),COLORFFFFFF;{在最后一个周期绘制RSI文字,颜色为白色}
A3:=RSI1>RSI2;{判断5日RSI是否大于13日RSI}
RSI金叉:IF(A3,3,0),COLORRED;{如果5日RSI大于13日RSI,标记为RSI金叉,颜色为红色}
RSV:=-(HHV(HIGH,13)-CLOSE)/(HHV(HIGH,13)-LLV(LOW,13))*100;{计算LWR的RSV值}
LWR1:=SMA(RSV,3,1);{计算LWR的LWR1值,即RSV的3日SMA}
LWR2:=SMA(LWR1,3,1);{计算LWR的LWR2值,即LWR1的3日SMA}
DRAWICON(LWR1>LWR2,4,1);{如果LWR1大于LWR2,绘制向上箭头图标}
DRAWICON(LWR1<LWR2,4,2);{如果LWR1小于LWR2,绘制向下箭头图标}
DRAWTEXT(ISLASTBAR=1,4,'.LWR'),COLORFFFFFF;{在最后一个周期绘制LWR文字,颜色为白色}
A4:=LWR1>LWR2;{判断LWR1是否大于LWR2}
LWR金叉:IF(A4,4,0),COLORRED;{如果LWR1大于LWR2,标记为LWR金叉,颜色为红色}
BBI:=(MA(CLOSE,3)+MA(CLOSE,6)+MA(CLOSE,12)+MA(CLOSE,24))/4;{计算BBI值,即四条不同周期均线的平均值}
DRAWICON(CLOSE>BBI,5,1);{如果收盘价大于BBI,绘制向上箭头图标}
DRAWICON(CLOSE<BBI,5,2);{如果收盘价小于BBI,绘制向下箭头图标}
DRAWTEXT(ISLASTBAR=1,5,'.BBI'),COLORFFFFFF;{在最后一个周期绘制BBI文字,颜色为白色}
A5:=CLOSE>BBI;{判断收盘价是否大于BBI}
BBI金叉:IF(A5,5,0),COLORRED;{如果收盘价大于BBI,标记为BBI金叉,颜色为红色}
MTM:=CLOSE-REF(CLOSE,1);{计算MTM值,即收盘价与前一日收盘价的差}
MMS:=100*EMA(EMA(MTM,5),3)/EMA(EMA(ABS(MTM),5),3);{计算MMS值,即MTM的5日EMA的3日EMA}
MMM:=100*EMA(EMA(MTM,13),8)/EMA(EMA(ABS(MTM),13),8);{计算MMM值,即MTM的13日EMA的8日EMA}
DRAWICON(MMS>MMM,6,1);{如果MMS大于MMM,绘制向上箭头图标}
DRAWICON(MMS<MMM,6,2);{如果MMS小于MMM,绘制向下箭头图标}
DRAWTEXT(ISLASTBAR=1,6,'.MTM'),COLORFFFFFF;{在最后一个周期绘制MTM文字,颜色为白色}
A6:=MMS>MMM;{判断MMS是否大于MMM}
MTM金叉:IF(A6,6,0),COLORRED;{如果MMS大于MMM,标记为MTM金叉,颜色为红色}
涨买入:IF((A1 AND A2 AND A3 AND A4 AND A5 AND A6) AND REF(A1 AND A2 AND A3 AND A4 AND A5 AND A6,1)=0,7,0),COLORYELLOW,LINETHICK2;{如果所有金叉条件满足且昨日不满足,标记为涨买入,颜色为黄色,线宽为2}
上涨:IF(A1 AND A2 AND A3 AND A4 AND A5 AND A6,7,0),COLORYELLOW,LINETHICK2;{如果所有金叉条件满足,标记为上涨,颜色为黄色,线宽为2}
晴天:BARSLASTCOUNT(A1 AND A2 AND A3 AND A4 AND A5 AND A6),LINETHICK0;{计算连续满足所有金叉条件的周期数,线宽为0}
雨天:BARSLASTCOUNT(MACD金叉+KDJ金叉+RSI金叉+LWR金叉+BBI金叉+MTM金叉>0 AND MACD金叉+KDJ金叉+RSI金叉+LWR金叉+BBI金叉+MTM金叉<21 ),LINETHICK0;{计算连续满足部分金叉条件但不超过21个周期的周期数,线宽为0}
雪天:BARSLASTCOUNT(MACD金叉+KDJ金叉+RSI金叉+LWR金叉+BBI金叉+MTM金叉=0),LINETHICK0;{计算完全不满足金叉条件的周期数,线宽为0}
选股公式:
DIFF:=EMA(CLOSE,8)-EMA(CLOSE,13);
DEA:=EMA(DIFF,5);
A1:=DIFF>DEA;
RSV1:=(CLOSE-LLV(LOW,8))/(HHV(HIGH,8)-LLV(LOW,8))*100;
K:=SMA(RSV1,3,1);
D:=SMA(K,3,1);
A2:=K>D;
LC:=REF(CLOSE,1);
RSI1:=(SMA(MAX(CLOSE-LC,0),5,1))/(SMA(ABS(CLOSE-LC),5,1))*100;
RSI2:=(SMA(MAX(CLOSE-LC,0),13,1))/(SMA(ABS(CLOSE-LC),13,1))*100;
A3:=RSI1>RSI2;
RSV:=-(HHV(HIGH,13)-CLOSE)/(HHV(HIGH,13)-LLV(LOW,13))*100;
LWR1:=SMA(RSV,3,1);
LWR2:=SMA(LWR1,3,1);
A4:=LWR1>LWR2;
BBI:=(MA(CLOSE,3)+MA(CLOSE,6)+MA(CLOSE,12)+MA(CLOSE,24))/4;
A5:=CLOSE>BBI;
MTM:=CLOSE-REF(CLOSE,1);
MMS:=100*EMA(EMA(MTM,5),3)/EMA(EMA(ABS(MTM),5),3);
MMM:=100*EMA(EMA(MTM,13),8)/EMA(EMA(ABS(MTM),13),8);
A6:=MMS>MMM;
涨买入:IF((A1 AND A2 AND A3 AND A4 AND A5 AND A6) AND REF(A1 AND A2 AND A3 AND A4 AND A5 AND A6,1)=0,7,0);