KDJ叠加RSI源码 副图 通达信 贴图 说明
{BY SHUHONG 改编}
{指标仅用于日线}
{KDJ日周}
N:=1;
日K:KDJ.K,COLORWHITE;
日D:KDJ.D,COLORYELLOW;
日J:KDJ.J,COLORMAGENTA;
周K:=KDJ.K#WEEK,NODRAW;
周D:=KDJ.D#WEEK,NODRAW;
周J:=KDJ.J#WEEK,NODRAW;
日金叉:=CROSS(日K,日D) AND (日D<40 OR 日D>60);
周金叉:=CROSS(周K,周D) AND (周D<40 OR 周D>60);
共振:=(周金叉 AND 日金叉);
STICKLINE(共振,-30,100,3,0),COLORLIRED;
DRAWTEXT((周金叉 AND 日金叉),-5,' 日周共振'),COLORYELLOW;
DRAWTEXT((周金叉 AND 日金叉),5,' K D J'),COLORYELLOW;
DRAWICON((周金叉 AND 日金叉),-5,5);
STICKLINE(日K>=日D,-15,-10,3,0),COLORLIRED;
STICKLINE(日K< 日D,-15,-10,3,0),COLORLIBLUE;
STICKLINE(周K>=周D,-20,-25,3,0),COLORLIRED;
STICKLINE(周K< 周D,-20,-25,3,0),COLORLIBLUE;
DRAWTEXT(ISLASTBAR,-12,'__日KDJ'),COLORWHITE;
DRAWTEXT(ISLASTBAR,-22,'__周KDJ'),COLORWHITE;
{RSI彩条}
LC1:=REF(CLOSE,1);
RSI11:=SMA(MAX(CLOSE-LC1,0),6,1)/SMA(ABS(CLOSE-LC1),6,1)*100,NODRAW;
RSI22:=SMA(MAX(CLOSE-LC1,0),12,1)/SMA(ABS(CLOSE-LC1),12,1)*100,NODRAW;
DRAWBAND(RSI11,RGB(150,0,0),RSI22,RGB(0,0,150));
RSI1:SMA(MAX(CLOSE-LC1,0),6,1)/SMA(ABS(CLOSE-LC1),6,1)*100,COLOR000096;
RSI2:SMA(MAX(CLOSE-LC1,0),12,1)/SMA(ABS(CLOSE-LC1),12,1)*100,COLOR000096;
IF(RSI1>RSI2,DRAWNULL,RSI1),COLOR960000;
IF(RSI1>RSI2,DRAWNULL,RSI2),COLOR960000;
{KDJ底背离和顶背离}
A2:=BARSLAST(REF(CROSS("KDJ.K"(9,3,3),"KDJ.D"(9,3,3)),1));
B2:=REF(C,A2+1)>C AND REF("KDJ.K"(9,3,3),A2+1)<"KDJ.K"(9,3,3) AND CROSS("KDJ.K"(9,3,3),"KDJ.D"(9,3,3));{KDJ底背}
C2:=BARSLAST(REF(CROSS("KDJ.D"(9,3,3),"KDJ.K"(9,3,3)),1));
D2:=REF(C,C2+1)<C AND REF("KDJ.K"(9,3,3),C2+1)>"KDJ.K"(9,3,3) AND CROSS("KDJ.D"(9,3,3),"KDJ.K"(9,3,3));{KDJ顶背}
DRAWICON((B2>0),日J,1);
DRAWTEXT((B2>0),日J,' KDJ底背'),COLORWHITE;
DRAWICON((D2>0),日J,2);
DRAWTEXT((D2>0),日J,' KDJ顶背'),COLORGREEN;
{RSI底背离和顶背离}
A3:=BARSLAST(REF(CROSS("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24)),1));
B3:=REF(C,A3+1)>C AND REF("RSI.RSI1"(6,12,24),A3+1)<"RSI.RSI1"(6,12,24) AND CROSS
("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24));
C3:=BARSLAST(REF(CROSS("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24)),1));
D3:=REF(C,C3+1)<C AND REF("RSI.RSI1"(6,12,24),C3+1)>"RSI.RSI1"(6,12,24) AND CROSS
("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24));
DRAWICON((D3>0),95,2);
DRAWTEXT((D3>0),95,' RSI顶背'),COLORCYAN;
DRAWICON((B3>0),20,1);
DRAWTEXT((B3>0),20,' RSI底背'),COLORRED;
{传统KDJ}
RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:SMA(RSV,3,1),COLORWHITE,LINETHICK1;
D:SMA(K,3,1),COLORYELLOW,LINETHICK1;
J:3*K-2*D,COLORMAGENTA,LINETHICK1;
IF1:IF(J<10,J,DRAWNULL),COLORRED,LINETHICK2;
IF2:IF(J>=80,J,DRAWNULL),COLORFF0080,LINETHICK2;
DRAWTEXT(ISLASTBAR,K,' ←K'),COLORWHITE;
DRAWTEXT(ISLASTBAR,D,' ←D'),COLORYELLOW;
DRAWTEXT(ISLASTBAR,J,' ←J'),COLORMAGENTA;
未来函数检测结果如下:
该公式包含未来函数:#WEEK
解密、编写股票、期货策略请联系QQ或微信同号:88652583
相关股票指标公式
原理解析:
{BY SHUHONG 改编}
{指标仅用于日线}
{KDJ日周}
N赋值:1
输出日K:KDJ.K,画白色
输出日D:KDJ.D,画黄色
输出日J:KDJ.J,画洋红色
周K赋值:KDJ.K#WEEK,NODRAW
周D赋值:KDJ.D#WEEK,NODRAW
周J赋值:KDJ.J#WEEK,NODRAW
日金叉赋值:日K上穿日D AND (日D<40 OR 日D>60)
周金叉赋值:周K上穿周D AND (周D<40 OR 周D>60)
共振赋值:(周金叉 AND 日金叉)
当满足条件共振时,在-30和100之间画柱状线
DRAWTEXT((周金叉 AND 日金叉),-5,' 日周共振'),画黄色
DRAWTEXT((周金叉 AND 日金叉),5,' K D J'),画黄色
DRAWICON((周金叉 AND 日金叉),-5,5)
当满足条件日K>=日D时,在-15和-10之间画柱状线
当满足条件日K< 日D时,在-15和-10之间画柱状线
当满足条件周K>=周D时,在-20和-25之间画柱状线
当满足条件周K< 周D时,在-20和-25之间画柱状线
当满足条件ISLASTBAR时,在-12和'__日KDJ'位置书写文字
当满足条件ISLASTBAR时,在-22和'__周KDJ'位置书写文字
{RSI彩条}
LC1赋值:1日前的收盘价
RSI11赋值:SMA(收盘价-LC1和0较大值,6,1)/SMA(收盘价-LC1的绝对值,6,1)*100,NODRAW
RSI22赋值:SMA(收盘价-LC1和0较大值,12,1)/SMA(收盘价-LC1的绝对值,12,1)*100,NODRAW
DRAWBAND(RSI11,RGB(150,0,0),RSI22,RGB(0,0,150))
输出RSI1:SMA(收盘价-LC1和0较大值,6,1)/SMA(收盘价-LC1的绝对值,6,1)*100,COLOR000096
输出RSI2:SMA(收盘价-LC1和0较大值,12,1)/SMA(收盘价-LC1的绝对值,12,1)*100,COLOR000096
如果RSI1>RSI2返回DRAWNULL否则返回RSI1
如果RSI1>RSI2返回DRAWNULL否则返回RSI2
{KDJ底背离和顶背离}
A2赋值:上次REF(CROSS("KDJ.K"(9,3,3距今天数,"KDJ.D"(9,3,3)),1))
B2赋值:A2+1日前的C>C AND REF("KDJ.K"(9,3,3),A2+1)<"KDJ.K"(9,3,3) AND CROSS("KDJ.K"(9,3,3),"KDJ.D"(9,3,3))
{KDJ底背}
C2赋值:上次REF(CROSS("KDJ.D"(9,3,3距今天数,"KDJ.K"(9,3,3)),1))
D2赋值:C2+1日前的C"KDJ.K"(9,3,3) AND CROSS("KDJ.D"(9,3,3),"KDJ.K"(9,3,3))
{KDJ顶背}
DRAWICON((B2>0),日J,1)
DRAWTEXT((B2>0),日J,' KDJ底背'),画白色
DRAWICON((D2>0),日J,2)
DRAWTEXT((D2>0),日J,' KDJ顶背'),画绿色
{RSI底背离和顶背离}
A3赋值:上次REF(CROSS("RSI.RSI1"(6,12,24距今天数,"RSI.RSI2"(6,12,24)),1))
B3赋值:A3+1日前的C>C AND REF("RSI.RSI1"(6,12,24),A3+1)<"RSI.RSI1"(6,12,24) AND CROSS
("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24))
C3赋值:上次REF(CROSS("RSI.RSI2"(6,12,24距今天数,"RSI.RSI1"(6,12,24)),1))
D3赋值:C3+1日前的C"RSI.RSI1"(6,12,24) AND CROSS
("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24))
DRAWICON((D3>0),95,2)
DRAWTEXT((D3>0),95,' RSI顶背'),画青色
DRAWICON((B3>0),20,1)
DRAWTEXT((B3>0),20,' RSI底背'),COLORRED
{传统KDJ}
RSV赋值:(收盘价-9日内最低价最低值)/(9日内最高价最高值-9日内最低价最低值)*100
RSV的3日[1日权重]移动平均
K的3日[1日权重]移动平均
输出J:3*K-2*D,画洋红色,LINETHICK1
如果输出1:J<10返回J否则返回DRAWNULL
如果输出2:J>=80返回J否则返回DRAWNULL
当满足条件ISLASTBAR时,在K和' ←K'位置书写文字
当满足条件ISLASTBAR时,在D和' ←D'位置书写文字
当满足条件ISLASTBAR时,在J和' ←J'位置书写文字