风险评测-精品通达信指标公式源码分享
{指标1,100,1}
RSVA1:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
RSVA2:=100*(HHV(HIGH,9)-CLOSE)/(HHV(HIGH,9)-LLV(LOW,9));
VAR21:=SMA(RSVA2,9,1)+100;
VAR11:=SMA(RSVA1,3,1);
VAR51:=SMA(VAR11,3,1)+100;
顶底线:=VAR51-VAR21+50;
R21:=SMA(RSVA2,9,1)+100;
VAR11:=SMA(RSVA1,3,1);
VAR51:=SMA(VAR11,3,1)+100;
顶底线:=VAR51-VAR21+50;
VAR2:=LLV(LOW,33);
VAR3:=HHV(HIGH,21);
VAR4:=EMA((CLOSE-VAR2)/(VAR3-VAR2)*100,10)*-1+100;
趋势:=100-EMA(0.191*REF(VAR4,1)+0.809*VAR4,1);
STICKLINE(C,100,90,4,0),COLORFFCC33;
STICKLINE(C,90,80,4,0),COLORFF9933;
STICKLINE(顶底线>REF(顶底线,1),20,80,4,0),COLOR9999FF;
STICKLINE(顶底线<REF(顶底线,1),20,80,4,0),COLOR009966;
STICKLINE((趋势>REF(趋势,1) AND 顶底线<REF(顶底线,1)),20,80,4,0),COLOR9999FF;
STICKLINE((趋势<REF(趋势,1) AND 顶底线>REF(顶底线,1)),20,80,4,0),COLOR009966;
STICKLINE(C,20,10,4,0),COLORFF6633;
STICKLINE(C,10,0,4,0),COLORFF3333;
10,COLORLIGRAY;
90,COLORLIGRAY;
{MACD}
Y:=(L+H)/2;
AO:=SMA(Y,5,1);
AC:=SMA(Y,34,1);
DIFZ:=(AO-AC)*10;
DH:=(SMA(DIFZ-SMA(DIFZ,3,1),2,1))*6,COLORSTICK;
RC:=50;
DRAWBAND(DIFZ+RC,RGB(185,50,50),EMA(DIFZ+RC,9),RGB(0,50,190));
DRAWBAND(-DIFZ+RC,RGB(0,50,190),EMA(-DIFZ+RC,9),RGB(185,50,50));
IF(C,DIFZ+RC,DRAWNULL),COLORRED,LINETHICK1;
IF(DIFZ<=REF(DIFZ,1),DIFZ+RC,DRAWNULL),COLORGRAY;
HS:RC,COLORYELLOW,LINETHICK1;
IF(DH>0,HS,DRAWNULL),COLOR2266FF,LINETHICK1;
IF(DH<=0,HS,DRAWNULL),COLORDDDD66,LINETHICK1;
STICKLINE(DH>0 AND DH>REF(DH,1),RC,RC+DH,1,0),COLORRED;
STICKLINE(DH>0 AND DH<=REF(DH,1),RC,RC+DH,1,0),COLORLIGREEN;
STICKLINE(DH<0 AND DH>REF(DH,1),RC,RC+DH,1,0),COLORLIRED;
STICKLINE(DH<0 AND DH<=REF(DH,1),RC,RC+DH,1,0),COLORLIBLUE;
DRAWTEXT(FILTER(CLOSE>0,25),5,'高安区'),COLORLIGRAY;
DRAWTEXT(FILTER(CLOSE>0,25),15,'安全区'),COLORLIGRAY;
DRAWTEXT(FILTER(CLOSE>0,25),35,'绿持币'),COLORYELLOW;
{DRAWTEXT(FILTER(CLOSE>0,25),50,'(投资区)'),COLORBROWN;}
DRAWTEXT(FILTER(CLOSE>0,25),75,'粉持股'),COLORYELLOW;
DRAWTEXT(FILTER(CLOSE>0,25),85,'风险区'),COLORBROWN;
DRAWTEXT(FILTER(CLOSE>0,25),95,'高险区'),COLORBROWN;
趋势线:100-EMA(0.191*REF(VAR4,1)+0.809*VAR4,1),LINETHICK2,COLORBLUE;
IF(趋势线>REF(趋势线,1),趋势线,DRAWNULL),COLORRED,LINETHICK2;
当前安全度:100-EMA(0.191*REF(VAR4,1)+0.809*VAR4,1),CIRCLEDOT,LINETHICK1,COLORBLUE;
IF(当前安全度>REF(当前安全度,1),当前安全度,DRAWNULL),CIRCLEDOT,COLORRED,LINETHICK2;
{背离}
短势:=IF(指标=1,"KDJ.K",IF(指标=2,"MACD.DIF",IF(指标=3,"CCI.CCI",IF(指标=4,"DMA.AMA",
IF(指标=5,"RSI.RSI1",IF(指标=6,"DMI.ADX",IF(指标=7,"PSY.PSY",IF(指标=8,"BIAS.BIAS1",
IF(指标=9,"CR.MA1",IF(指标=10,"MTM.MTM","VMA.VMA1"))))))))));
局部低点预选A:=BACKSET(LLV(L,5)<REF(LLV(L,4),1),4);
局部低点预选B:=BACKSET(局部低点预选A=0 AND REF(局部低点预选A,1)=1,2);
局部低点预选C:=IF(局部低点预选B=1 AND REF(局部低点预选B,1)=0,-1,0);
局部高点预选A:=BACKSET(HHV(H,5)>REF(HHV(H,4),1),4);
局部高点预选B:=BACKSET(局部高点预选A=0 AND REF(局部高点预选A,1)=1,2);
局部高点预选C:=IF(局部高点预选B=1 AND REF(局部高点预选B,1)=0,1,0);
缺口判断:=IF(L>REF(H,1),1,IF(H<REF(L,1),-1,0));
距前高天:=BARSLAST(局部高点预选C=1);
距前低天:=BARSLAST(局部低点预选C=-1);
小值周期:=LOWRANGE(L);
大值周期:=TOPRANGE(H);
低保留AA:=IF(局部低点预选C=-1 AND REF(距前高天,1)>REF(距前低天,1) AND LLV(L,距前高天+1)<REF(LLV(L,距前高天+1),1),-1,0);
低保留AB:=IF(局部低点预选C=-1 AND REF(距前高天,1)<=REF(距前低天,1) AND (距前高天>=4 OR LLV(缺口判断,距前高天)=-1 OR LLV(L,距前低天+2)<REF(LLV(L,距前低天+1),1)),-1,0);
低保留S:=IF((低保留AA=-1 OR 低保留AB=-1) AND L<REF(H,距前高天+1),-1,0);
预判:=IF((距前低天<4 AND HHV(缺口判断,距前低天)!=1) OR REF(低保留S,距前低天)=0,1,0);
判断:=IF(局部高点预选C=1 AND REF(距前低天,1)<=REF(距前高天,1) AND 预判=1 AND 大值周期>REF(小值周期,距前低天+1) AND 大值周期>REF(小值周期,距前低天) AND 大值周期>REF(大值周期,距前高天),1,0);
高保留A:=IF(局部高点预选C=1 AND REF(距前低天,1)>REF(距前高天,1) AND HHV(H,距前低天+1)>REF(HHV(H,距前低天+1),1),1,0);
高保留B:=IF(局部高点预选C=1 AND REF(距前低天,1)<=REF(距前高天,1) AND REF(低保留S,距前低天)=-1 AND (距前低天>=4 OR HHV(缺口判断,距前低天)=1),1,0);
高保留:=IF((高保留A=1 OR 高保留B=1 OR 判断=1) AND H>REF(L,距前低天+1),1,0);
预判A:=IF((距前高天<4 AND HHV(缺口判断,距前高天)!=1) OR REF(高保留,距前高天)=0,1,0);
判断A:=IF(局部低点预选C=-1 AND REF(距前高天,1)<=REF(距前低天,1) AND 预判A=1 AND 小值周期>REF(大值周期,距前高天+1) AND 小值周期>REF(大值周期,距前高天) AND 小值周期>REF(小值周期,距前低天),-1,0);
低保留A:=IF(局部低点预选C=-1 AND REF(距前高天,1)>REF(距前低天,1) AND LLV(L,距前高天+1)<REF(LLV(L,距前高天+1),1),-1,0);
低保留B:=IF(局部低点预选C=-1 AND REF(距前高天,1)<=REF(距前低天,1) AND (距前高天>=4 OR LLV(缺口判断,距前高天)=-1 OR 判断A=-1),-1,0);
低保留:=IF((低保留A=-1 OR 低保留B=-1) AND L<REF(H,距前高天+1),-1,0);
距前高天A:=BARSLAST(高保留=1);
距前低天A:=BARSLAST(低保留=-1);
预判X:=IF((距前低天A<4 AND HHV(缺口判断,距前低天A)!=1) OR REF(低保留,距前低天A)=0,1,0);
判断X:=IF(局部高点预选C=1 AND REF(距前低天A,1)<=REF(距前高天A,1) AND 预判X=1 AND 大值周期>REF(小值周期,距前低天A+1) AND 大值周期>REF(小值周期,距前低天A) AND 大值周期>REF(大值周期,距前高天A),1,0);
高保留XA:=IF(局部高点预选C=1 AND REF(距前低天A,1)>REF(距前高天A,1) AND HHV(H,距前低天A+1)>REF(HHV(H,距前低天A+1),1),1,0);
高保留XB:=IF(局部高点预选C=1 AND REF(距前低天A,1)<=REF(距前高天A,1) AND REF(低保留,距前低天A)=-1 AND (距前低天A>=4 OR HHV(缺口判断,距前低天A)=1),1,0);
高保留X:=IF((高保留XA=1 OR 高保留XB=1 OR 判断X=1) AND H>REF(L,距前低天A+1),1,0);
预判XA:=IF((距前高天A<4 AND HHV(缺口判断,距前高天A)!=1) OR REF(高保留XA,距前高天A)=0,1,0);
判断XA:=IF(局部低点预选C=-1 AND REF(距前高天A,1)<=REF(距前低天A,1) AND 预判XA=1 AND 小值周期>REF(大值周期,距前高天A+1) AND 小值周期>REF(大值周期,距前高天A) AND 小值周期>REF(小值周期,距前低天A),-1,0);
低保留XA:=IF(局部低点预选C=-1 AND REF(距前高天A,1)>REF(距前低天A,1) AND LLV(L,距前高天A+1)<REF(LLV(L,距前高天A+1),1),-1,0);
低保留XB:=IF(局部低点预选C=-1 AND REF(距前高天A,1)<=REF(距前低天A,1) AND (距前高天A>=4 OR LLV(缺口判断,距前高天A)=-1 OR 判断XA=-1),-1,0);
低保留X:=IF((低保留XA=-1 OR 低保留XB=-1) AND L<REF(H,距前高天A+1),-1,0);
距前高天YA:=BARSLAST(高保留X=1);
距前低天YA:=BARSLAST(低保留X=-1);
预判YX:=IF((距前低天YA<4 AND HHV(缺口判断,距前低天YA)!=1) OR REF(低保留X,距前低天YA)=0,1,0);
判断YX:=IF(局部高点预选C=1 AND REF(距前低天YA,1)<=REF(距前高天YA,1) AND 预判YX=1 AND 大值周期>REF(小值周期,距前低天YA+1) AND 大值周期>REF(小值周期,距前低天YA) AND 大值周期>REF(大值周期,距前高天YA),1,0);
高保留YXA:=IF(局部高点预选C=1 AND REF(距前低天YA,1)>REF(距前高天YA,1) AND HHV(H,距前低天YA+1)>REF(HHV(H,距前低天YA+1),1),1,0);
高保留YXB:=IF(局部高点预选C=1 AND REF(距前低天YA,1)<=REF(距前高天YA,1) AND REF(低保留X,距前低天YA)=-1 AND (距前低天YA>=4 OR HHV(缺口判断,距前低天YA)=1),1,0);
高保留YX:=IF((高保留YXA=1 OR 高保留YXB=1 OR 判断YX=1) AND H>REF(L,距前低天YA+1),1,0);
预判YXA:=IF((距前高天YA<4 AND HHV(缺口判断,距前高天YA)!=1) OR REF(高保留YXA,距前高天YA)=0,1,0);
判断YXA:=IF(局部低点预选C=-1 AND REF(距前高天YA,1)<=REF(距前低天YA,1) AND 预判YXA=1 AND 小值周期>REF(大值周期,距前高天YA+1) AND 小值周期>REF(大值周期,距前高天YA) AND 小值周期>REF(小值周期,距前低天YA),-1,0);
低保留YXA:=IF(局部低点预选C=-1 AND REF(距前高天YA,1)>REF(距前低天YA,1) AND LLV(L,距前高天YA+1)<REF(LLV(L,距前高天YA+1),1),-1,0);
低保留YXB:=IF(局部低点预选C=-1 AND REF(距前高天YA,1)<=REF(距前低天YA,1) AND (距前高天YA>=4 OR LLV(缺口判断,距前高天YA)=-1 OR 判断YXA=-1),-1,0);
低保留YX:=IF((低保留YXA=-1 OR 低保留YXB=-1) AND L<REF(H,距前高天YA+1),-1,0);
AAAD:=IF(高保留YX=1 AND 低保留YX=-1 AND H>REF(H,REF(距前高天YA,1)+2),1,IF(高保留YX=1 AND 低保留YX=-1 AND L<REF(L,REF(距前低天YA,1)+2),-1,0));
极点保留:=IF(AAAD=0,高保留YX+低保留YX,AAAD);
局部高:=DRAWLINE(极点保留=1,短势,极点保留=1,短势,1),COLOR00FFFF;
局部低:=DRAWLINE(极点保留=-1,短势,极点保留=-1,短势,1),COLORFF0000;
局部势高:=DRAWLINE(极点保留=1,H,极点保留=1,H,1),COLOR00FFFF;
局部势低:=DRAWLINE(极点保留=-1,L,极点保留=-1,L,1),COLORFF0000;
对比高离:=IF(局部势高>REF(局部势高,1)&&局部高<REF(局部高,1),0.5,1),COLOR8F00F8;
对比低背:=IF(局部势低<REF(局部势低,1)&&局部低>REF(局部低,1),0.5,0),COLOR00FF00;
DRAWICON(REF(对比高离,1)=1&&对比高离=0.5,趋势线,2);
DRAWICON(REF(对比低背,1)=0&&对比低背=0.5,趋势线,1);
DRAWTEXT(指标=0&&CURRBARSCOUNT=18,0.5+RC,'VMA.VMA1');
DRAWTEXT(指标=1&&CURRBARSCOUNT=18,0.5+RC,'KDJ.K');
DRAWTEXT(指标=10&&CURRBARSCOUNT=18,0.5+RC,'MTM.MTM');
版权声明
本文版权归掌上指标所有。
未经许可,不得转载,转载请注明出处!