通达信美化RSI波段副图指标 源码分享 附图
N1:=5;
N2:=10;
N3:=20;
P:=3;
{RSI划线}
{N1:2,120,5;N2:2,250,10;N3:2,500,20;}
{参数:P:1,20,3;}{支撑压力线的周期参数 P可调}
STICKLINE(C>0,0,30,10,0),COLOR353535;
STICKLINE(C>0,30,50,10,0),COLOR454545;
STICKLINE(C>0,50,80,10,0),COLOR555555;
STICKLINE(C>0,80,95,10,0),COLOR757575;
强弱线:50,LINETHICK2,COLOR858585;
警示线:80,POINTDOT,COLORCYAN;
减仓线:90,COLOR00AA55,LINETHICK2;
清仓线:95,COLOR0000AA,LINETHICK2;
LC:=REF(CLOSE,1);
RSI5:SMA(MAX(CLOSE-LC,0),N1,1)/SMA(ABS(CLOSE-LC),N1,1)*100,NODRAW,COLORFFAAFF;
RSI10:SMA(MAX(CLOSE-LC,0),N2,1)/SMA(ABS(CLOSE-LC),N2,1)*100,NODRAW,COLORDDAADD;
RSI20:SMA(MAX(CLOSE-LC,0),N3,1)/SMA(ABS(CLOSE-LC),N3,1)*100,NODRAW,COLORAA99AA;
DRAWBAND(RSI5,RGB(195,125,195),RSI10,RGB(0,130,50));
DRAWBAND(RSI10,RGB(165,95,165),RSI20,RGB(0,100,20));
{金叉死叉}
金叉:CROSS(RSI5,RSI20) AND CROSS(RSI10,RSI20),COLORRED,NODRAW;
DRAWTEXT(金叉,RSI5,'←'),COLORRED;
死叉:CROSS(RSI20,RSI10) AND CROSS(RSI20,RSI5),COLORGREEN,NODRAW;
DRAWTEXT(死叉,RSI5,'←'),COLORGREEN;
{RSI顶底背离}
RS:=BARSLAST(REF(CROSS(RSI20,RSI5),1));
RS1:=REF(CLOSE,RS+1)<CLOSE AND REF(RSI5,RS+1)>RSI5 AND CROSS(RSI20,RSI5);
顶背离:IF(RS1,RSI5,DRAWNULL),CIRCLEDOT,COLORFFCC00;
STICKLINE(RS1,RSI5,RSI5*0.9,0,0),COLORFFCC00;
DRAWTEXT(RS1,RSI5*0.9,'顶背离'),COLORFFCC00;
S1:=BARSLAST(REF(CROSS(RSI5,RSI20),1));
S1A:=REF(CLOSE,S1+1)>CLOSE AND RSI5>REF(RSI5,S1+1) AND
CROSS(RSI5,RSI20);
底背离:IF(S1A,RSI5,DRAWNULL),CIRCLEDOT,COLOR6699FF;
STICKLINE(S1A,RSI5,RSI5*1.1,0,0),COLOR6699FF;
DRAWTEXT(S1A,RSI5*1.1,'底背离'),COLOR6699FF;
{RSI划线}
OB:=RSI5;
A1:=REF(OB,P)=HHV(OB,2*P+1);
B1:=FILTER(A1,P);
C1:=BACKSET(B1,P+1);
D1:=FILTER(C1,P);{高点}
A2:=REF(OB,P)=LLV(OB,2*P+1);
B2:=FILTER(A2,P);
C2:=BACKSET(B2,P+1);
D2:=FILTER(C2,P);{低点}
R11:=BACKSET(ISLASTBAR,BARSLAST(D1)+1);
S11:=R11>REF(R11,1);
压力线:DRAWLINE(D1,OB,S11,OB,1),LINETHICK1,COLORCC33CC;
T11:=BACKSET(ISLASTBAR,BARSLAST(D2)+1);
U11:=T11>REF(T11,1);
支撑线:DRAWLINE(D2,OB,U11,OB,1),COLOR00CCCC;
DRAWTEXT(CURRBARSCOUNT=60,25,'强弱用来看趋势 背离用来看顶底'),COLORYELLOW;
DRAWTEXT(CURRBARSCOUNT=60,15,'支撑压力辨起落 设定周期参数 P'),COLORGREEN;
未来函数检测结果如下:
该公式包含未来函数:BACKSET
解密、编写股票、期货策略请联系QQ或微信同号:88652583
相关股票指标公式
原理解析:
N1赋值:5
N2赋值:10
N3赋值:20
P赋值:3
{RSI划线}
{输出N1:2,120,5
输出N2:2,250,10
输出N3:2,500,20
}
{参数:输出P:1,20,3
当满足条件C>0时,在0和30之间画柱状线
当满足条件C>0时,在30和50之间画柱状线
当满足条件C>0时,在50和80之间画柱状线
当满足条件C>0时,在80和95之间画柱状线
输出强弱线:50, 线宽为2,COLOR858585
输出警示线:80,POINTDOT,画青色
输出减仓线:90,COLOR00AA55, 线宽为2
输出清仓线:95,COLOR0000AA, 线宽为2
LC赋值:1日前的收盘价
输出RSI5:SMA(收盘价-LC和0较大值,N1,1)/SMA(收盘价-LC的绝对值,N1,1)*100,NODRAW,COLORFFAAFF
输出RSI10:SMA(收盘价-LC和0较大值,N2,1)/SMA(收盘价-LC的绝对值,N2,1)*100,NODRAW,COLORDDAADD
输出RSI20:SMA(收盘价-LC和0较大值,N3,1)/SMA(收盘价-LC的绝对值,N3,1)*100,NODRAW,COLORAA99AA
DRAWBAND(RSI5,RGB(195,125,195),RSI10,RGB(0,130,50))
DRAWBAND(RSI10,RGB(165,95,165),RSI20,RGB(0,100,20))
输出{金叉死叉}
金叉:RSI5上穿RSI20 AND RSI10上穿RSI20,画红色,NODRAW
当满足条件金叉时,在RSI5和'←'位置书写文字
输出死叉:RSI20上穿RSI10 AND RSI20上穿RSI5,画绿色,NODRAW
当满足条件死叉时,在RSI5和'←'位置书写文字
{RSI顶底背离}
RS赋值:上次1日前的RSI20上穿RSI5距今天数
RS1赋值:RS+1日前的收盘价<收盘价 AND RS+1日前的RSI5>RSI5 AND RSI20上穿RSI5
如果RS1返回RSI5否则返回DRAWNULL
当满足条件RS1时,在RSI5和RSI5*0.9之间画柱状线
当满足条件RS1时,在RSI5*0.9和'顶背离'位置书写文字
S1赋值:上次1日前的RSI5上穿RSI20距今天数
S1A:=S1+1日前的收盘价>收盘价 AND RSI5>S1+1日前的RSI5 AND
RSI5上穿RSI20
如果S1A返回RSI5否则返回DRAWNULL
当满足条件S1A时,在RSI5和RSI5*1.1之间画柱状线
当满足条件S1A时,在RSI5*1.1和'底背离'位置书写文字
{RSI划线}
OB赋值:RSI5
A1赋值:P日前的OB=2*P+1日内OB最高值
B1赋值:A1的P过滤
C1赋值:BACKSET(B1,P+1)
D1赋值:C1的P过滤
{高点}
A2赋值:P日前的OB=2*P+1日内OB最低值
B2赋值:A2的P过滤
C2赋值:BACKSET(B2,P+1)
D2赋值:C2的P过滤
{低点}
R11赋值:BACKSET(ISLASTBAR,上次D1距今天数+1)
S11:=R11>1日前的R11
输出压力线:DRAWLINE(D1,OB,S11,OB,1),LINETHICK1,COLORCC33CC
T11赋值:BACKSET(ISLASTBAR,上次D2距今天数+1)
U11赋值:T11>1日前的T11
输出支撑线:DRAWLINE(D2,OB,U11,OB,1),COLOR00CCCC
当满足条件 到最后交易的周期=60时,在25和'强弱用来看趋势 背离用来看顶底'位置书写文字
当满足条件 到最后交易的周期=60时,在15和'支撑压力辨起落 设定周期参数 P'位置书写文字