通达信交通规则指标公式
UR:=15;{0~200可调}
LR:=15;{0~200可调}
DA1:=IF(130>TOTALBARSCOUNT,TOTALBARSCOUNT,130);
DA:=IF(CURRBARSCOUNT>DA1,0,DA1);
HI:=REFDATE(HHV(H,DA),DATE);
LO:=REFDATE(LLV(L,DA),DATE);
C1:=IF(CURRBARSCOUNT<=DA,C,DRAWNULL);
GZ:=EXP(LN(HI/LO)/10);
LH1:=SUM(IF(C1>=(HI/GZ),V,0),DA);
LH2:=SUM(IF(C1>=(HI/POW(GZ,2)) AND C1<(HI/GZ),V,0),DA);
LH3:=SUM(IF(C1>=(HI/POW(GZ,3)) AND C1<(HI/POW(GZ,2)),V,0),DA);
LH4:=SUM(IF(C1>=(HI/POW(GZ,4)) AND C1<(HI/POW(GZ,3)),V,0),DA);
LH5:=SUM(IF(C1>=(HI/POW(GZ,5)) AND C1<(HI/POW(GZ,4)),V,0),DA);
LH6:=SUM(IF(C1>=(HI/POW(GZ,6)) AND C1<(HI/POW(GZ,5)),V,0),DA);
LH7:=SUM(IF(C1>=(HI/POW(GZ,7)) AND C1<(HI/POW(GZ,6)),V,0),DA);
LH8:=SUM(IF(C1>=(HI/POW(GZ,8)) AND C1<(HI/POW(GZ,7)),V,0),DA);
LH9:=SUM(IF(C1>=(LO*GZ) AND C1<LO*POW(GZ,2),V,0),DA);
LH10:=SUM(IF(C1>=LO AND C1<LO*GZ,V,0),DA);
L1:=REFDATE(HHV(LH1,DA),DATE);
L2:=REFDATE(HHV(LH2,DA),DATE);
L3:=REFDATE(HHV(LH3,DA),DATE);
L4:=REFDATE(HHV(LH4,DA),DATE);
L5:=REFDATE(HHV(LH5,DA),DATE);
L6:=REFDATE(HHV(LH6,DA),DATE);
L7:=REFDATE(HHV(LH7,DA),DATE);
L8:=REFDATE(HHV(LH8,DA),DATE);
L9:=REFDATE(HHV(LH9,DA),DATE);
L10:=REFDATE(HHV(LH10,DA),DATE);
SS:=(L1+L2+L3+L4+L5+L6+L7+L8+L9+L10);
STICKLINE(CEILING(DA*L1/SS)*3>=CURRBARSCOUNT,HI*99/100,HI/GZ,9,0),
,COLORLIGRAY,LINETHICK3;
STICKLINE(CEILING(DA*L2/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,1)*99/100
,HI/POW(GZ,2),9,0),COLORWHITE,LINETHICK3;
STICKLINE(CEILING(DA*L3/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,2)*99/100
,HI/POW(GZ,3),9,0),COLOR808300,LINETHICK3;
STICKLINE(CEILING(DA*L4/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,3)*99/100
,HI/POW(GZ,4),9,0),COLOR883D88,LINETHICK3;
STICKLINE(CEILING(DA*L5/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,4)*99/100
,HI/POW(GZ,5),9,0),COLOR777700,LINETHICK3;
STICKLINE(CEILING(DA*L6/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,5)*99/100
,HI/POW(GZ,6),9,0),COLOR804000,LINETHICK3;
STICKLINE(CEILING(DA*L7/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,6)*99/100
,HI/POW(GZ,7),9,0),COLOR003377,LINETHICK3;
STICKLINE(CEILING(DA*L8/SS)*3>=CURRBARSCOUNT,LO*POW(GZ,2),LO*POW(GZ,3)
*99/100,9,0),COLORLICYAN,LINETHICK3;
STICKLINE(CEILING(DA*L9/SS)*3>=CURRBARSCOUNT,LO*POW(GZ,1),LO*POW(GZ,2)
*99/100,9,0),COLORLIMAGENTA,LINETHICK3;
STICKLINE(CEILING(DA*L10/SS)*3>=CURRBARSCOUNT,LO,LO*POW(GZ,1)*99/100,9,0)
,COLORBROWN,LINETHICK3;
DRAWKLINE(H,O,L,C);
TC1:=IF(H=HHV(H,8*UR),H,DRAWNULL);
TC2:=CONST(BARSLAST(TC1=H))+1;
BC1:=IF(L=LLV(L,8*LR),L,DRAWNULL);
BC2:=CONST(BARSLAST(BC1=L))+1;
NOD:=(IF(TC2>BC2,TC2,BC2)-IF(TC2>BC2,BC2,TC2));
LR1:=FORCAST(C,NOD+1);
NP:IF(CURRBARSCOUNT<=MAX(BC2,TC2),CONST(IF(MIN(TC2,BC2)=1,LR1,REF(LR1,MIN(TC2,BC2)-1))),DRAWNULL),POINTDOT,COLOR93BDA8;
LR2:=SLOPE(C,NOD+1);
LR3:=CONST(IF(MIN(TC2,BC2)=1,LR2,REF(LR2,MIN(TC2,BC2)-1)));
FP:NP-LR3*(NOD),POINTDOT,COLOR93BDA8;
AD:=ABS(NP-FP);
DBL:=BARSLAST(BC1!=DRAWNULL)+1;
DBH:=BARSLAST(TC1!=DRAWNULL)+1;
BSP:=IF(BC2>TC2,DBL,DBH)-1;
LRL:=IF(NP>FP,FP+AD/NOD*BSP,FP-AD/NOD*BSP);
AT1:=IF(BETWEEN(CURRBARSCOUNT,BC2,TC2) AND H>LRL,H,LRL);
AT2:=HHV(AT1-LRL,MAX(BC2,TC2));
AT3:=CONST(BARSLAST(AT1-LRL=AT2));
AT5:=CONST(IF(AT3=0,AT1-LRL,REF(AT1-LRL,AT3)));
ATL:=LRL+AT5;
UT1:=IF(BETWEEN(CURRBARSCOUNT,BC2,TC2) AND L<LRL,L,LRL);
UT2:=HHV(LRL-UT1,MAX(BC2,TC2));
UT3:=CONST(BARSLAST(LRL-UT1=UT2));
UT5:=CONST(IF(UT3=0,LRL-UT1,REF(LRL-UT1,UT3)));
UTL:=LRL-UT5;
RH:=IF(CURRBARSCOUNT>=MIN(BC2,TC2)-10,ATL,CONST(REF(ATL,MIN(BC2,TC2)-11)));
RL:=IF(CURRBARSCOUNT>=MIN(BC2,TC2)-10,UTL,CONST(REF(UTL,MIN(BC2,TC2)-11)));
上轨:=IF(NP>FP,IF(ATL<=RH,ATL,DRAWNULL),IF(ATL>=RL,ATL,DRAWNULL)),COLORBLUE,LINETHICK2;
下轨:=IF(NP>FP,IF(UTL<=RH,UTL,DRAWNULL),IF(UTL>=RL,UTL,DRAWNULL)),COLORMAGENTA ,LINETHICK2;
操作2:=(C*4+L*3+H*2+O)/10,COLORGREEN,LINETHICK1;
P:=14;
A1Z:=REF(操作2,P)=HHV(操作2,2*P+1);
B1:=FILTER(A1Z,P);
C1Z:=BACKSET(B1,P+1);
D1:=FILTER(C1Z,P);{高点}
A2Z:=REF(操作2,P)=LLV(操作2,2*P+1);
B2:=FILTER(A2Z,P);
C2Z:=BACKSET(B2,P+1);
D2:=FILTER(C2Z,P);{低点}
下:=REF(操作2,BARSLAST(D2)),COLOR00FF00,NODRAW;
上:=REF(操作2,BARSLAST(D1)),COLORFF00FF,NODRAW;
STICKLINE(REF(操作2=下,1) AND 操作2>下轨,L,L-0.3,3,0),COLORGRAY;
STICKLINE(REF(操作2=下,1) AND 操作2>下轨,L-0.05,L-0.25,2,0),COLORGREEN ;
DRAWTEXT(REF(操作2=下,1) AND 操作2>下轨,L-0.4,'绿灯')COLORGREEN;
STICKLINE(操作2=上,H,H+0.3,3,0),COLORYELLOW ;
STICKLINE(操作2=上,H+0.05,H+0.25,2,0),COLORRED ;
DRAWTEXT(操作2=上,H+0.4,'红灯')COLORRED;
Z:ZIG(3,上),COLORFFFFFF;
LC:=REF(CLOSE,1);
RSI5:=((SMA(MAX((CLOSE - LC),0),5,1) / SMA(ABS((CLOSE - LC)),5,1)) * 100);
TR1:=SUM(MAX(MAX((HIGH - LOW),ABS((HIGH - REF(CLOSE,1)))),ABS((LOW - REF(CLOSE,1)))),10);
HD:=(HIGH - REF(HIGH,1));
LD:=(REF(LOW,1) - LOW);
DMP:=SUM(IF(((HD > 0) AND (HD > LD)),HD,0),10);
DMM:=SUM(IF(((LD > 0) AND (LD > HD)),LD,0),10);
PDI:=((DMP * 100) / TR1);
MDI:=((DMM * 100) / TR1);
ADX:=MA(((ABS((MDI - PDI)) / (MDI + PDI)) * 100),5);
AV:=(RSI5 + ADX);
WR10:=((100 *( HHV(HIGH,10) - CLOSE)) / (HHV(HIGH,10) - LLV(LOW,10)));
NEWVOL:=(RSI5 - WR10);
回调买:=(AV + NEWVOL);
DRAWTEXT(CROSS(回调买,0),L*0.86,'↖回调买'),COLORYELLOW;
MT1:=IF(ISLASTBAR,REF((C*2-REF(C,3)),1),DRAWNULL);
MT2:=IF(ISLASTBAR,REF((C*2-REF(C,3)),2),DRAWNULL);
MT3:=IF(ISLASTBAR,C*2-REF(C,3),DRAWNULL);
DRAWTEXT(ISLASTBAR,MT2,' ●'),COLORMAGENTA,LINETHICK2;
DRAWTEXT(ISLASTBAR,MT1,' ●'),COLORMAGENTA,LINETHICK2;
DRAWTEXT(ISLASTBAR,MT3,' ●'),COLORMAGENTA,LINETHICK2;
未来函数检测结果如下:
该公式包含未来函数:ZIG
该公式包含未来函数:BACKSET
解密、定制、编写股票指标请联系QQ或微信同号:88652583
相关股票指标公式
原理解析:
UR赋值:15
{0~200可调}
LR赋值:15
如果130>TOTALBARSCOUNT返回TOTALBARSCOUNT否则返回130
如果CURRBARSCOUNT>DA1返回0否则返回DA1
HI赋值:REFDATE(DA日内H最高值,DATE)
LO赋值:REFDATE(DA日内L最低值,DATE)
如果CURRBARSCOUNT<=DA返回C否则返回DRAWNULL
GZ赋值:EXP(LN(HI/LO)/10)
LH1赋值:SUM(IF(C1>=(HI/GZ),V,0),DA)
LH2赋值:SUM(IF(C1>=(HI/POW(GZ,2)) AND C1<(HI/GZ),V,0),DA)
LH3赋值:SUM(IF(C1>=(HI/POW(GZ,3)) AND C1<(HI/POW(GZ,2)),V,0),DA)
LH4赋值:SUM(IF(C1>=(HI/POW(GZ,4)) AND C1<(HI/POW(GZ,3)),V,0),DA)
LH5赋值:SUM(IF(C1>=(HI/POW(GZ,5)) AND C1<(HI/POW(GZ,4)),V,0),DA)
LH6赋值:SUM(IF(C1>=(HI/POW(GZ,6)) AND C1<(HI/POW(GZ,5)),V,0),DA)
LH7赋值:SUM(IF(C1>=(HI/POW(GZ,7)) AND C1<(HI/POW(GZ,6)),V,0),DA)
LH8赋值:SUM(IF(C1>=(HI/POW(GZ,8)) AND C1<(HI/POW(GZ,7)),V,0),DA)
LH9赋值:SUM(IF(C1>=(LO*GZ) AND C1如果C1>=LO AND C1
L1赋值:REFDATE(DA日内LH1最高值,DATE)
L2赋值:REFDATE(DA日内LH2最高值,DATE)
L3赋值:REFDATE(DA日内LH3最高值,DATE)
L4赋值:REFDATE(DA日内LH4最高值,DATE)
L5赋值:REFDATE(DA日内LH5最高值,DATE)
L6赋值:REFDATE(DA日内LH6最高值,DATE)
L7赋值:REFDATE(DA日内LH7最高值,DATE)
L8赋值:REFDATE(DA日内LH8最高值,DATE)
L9赋值:REFDATE(DA日内LH9最高值,DATE)
L10:=REFDATE(DA日内LH10最高值,DATE)
SS赋值:(L1+L2+L3+L4+L5+L6+L7+L8+L9+L10)
STICKLINE(CEILING(DA*L1/SS)*3>=CURRBARSCOUNT,HI*99/100,HI/GZ,9,0),
,COLORLIGRAY, 线宽为3
STICKLINE(CEILING(DA*L2/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,1)*99/100
,HI/POW(GZ,2),9,0),画白色, 线宽为3
STICKLINE(CEILING(DA*L3/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,2)*99/100
,HI/POW(GZ,3),9,0),COLOR808300, 线宽为3
STICKLINE(CEILING(DA*L4/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,3)*99/100
,HI/POW(GZ,4),9,0),COLOR883D88, 线宽为3
STICKLINE(CEILING(DA*L5/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,4)*99/100
,HI/POW(GZ,5),9,0),COLOR777700, 线宽为3
STICKLINE(CEILING(DA*L6/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,5)*99/100
,HI/POW(GZ,6),9,0),COLOR804000, 线宽为3
STICKLINE(CEILING(DA*L7/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,6)*99/100
,HI/POW(GZ,7),9,0),COLOR003377, 线宽为3
STICKLINE(CEILING(DA*L8/SS)*3>=CURRBARSCOUNT,LO*POW(GZ,2),LO*POW(GZ,3)
*99/100,9,0),COLORLICYAN, 线宽为3
STICKLINE(CEILING(DA*L9/SS)*3>=CURRBARSCOUNT,LO*POW(GZ,1),LO*POW(GZ,2)
*99/100,9,0),COLORLIMAGENTA, 线宽为3
STICKLINE(CEILING(DA*L10/SS)*3>=CURRBARSCOUNT,LO,LO*POW(GZ,1)*99/100,9,0)
,COLORBROWN, 线宽为3
DRAWKLINE(H,O,L,C)
TC1赋值:IF(H=8*UR日内H最高值,H,DRAWNULL)
TC2赋值:CONST(上次TC1=H距今天数)+1
BC1赋值:IF(L=8*LR日内L最低值,L,DRAWNULL)
BC2赋值:CONST(上次BC1=L距今天数)+1
如果TC2>BC2返回TC2否则返回BC2
LR1赋值:FORCAST(C,NOD+1)
输出
NP:IF(CURRBARSCOUNT<=BC2和TC2较大值,CONST(IF(TC2和BC2的较小值=1,LR1,REF(LR1,TC2和BC2的较小值-1))),DRAWNULL),POINTDOT,COLOR93BDA8
LR2赋值:SLOPE(C,NOD+1)
LR3赋值:CONST(IF(TC2和BC2的较小值=1,LR2,REF(LR2,TC2和BC2的较小值-1)))
输出
FP:NP-LR3*(NOD),POINTDOT,COLOR93BDA8
AD赋值:NP-FP的绝对值
DBL赋值:上次BC1!=DRAWNULL距今天数+1
DBH赋值:上次TC1!=DRAWNULL距今天数+1
如果BC2>TC2返回DBL否则返回DBH
如果NP>FP返回FP+AD/NOD*BSP否则返回FP-AD/NOD*BSP
AT1赋值:IF(BETWEEN(CURRBARSCOUNT,BC2,TC2) AND H>LRL,H,LRL)
AT2赋值:BC2和TC2较大值日内AT1-LRL最高值
AT3赋值:CONST(上次AT1-LRL=AT2距今天数)
AT5赋值:CONST(IF(AT3=0,AT1-LRL,AT3日前的AT1-LRL))
ATL赋值:LRL+AT5
UT1赋值:IF(BETWEEN(CURRBARSCOUNT,BC2,TC2) AND L
UT2赋值:BC2和TC2较大值日内LRL-UT1最高值
UT3赋值:CONST(上次LRL-UT1=UT2距今天数)
UT5赋值:CONST(IF(UT3=0,LRL-UT1,UT3日前的LRL-UT1))
UTL赋值:LRL-UT5
RH赋值:IF(CURRBARSCOUNT>=BC2和TC2的较小值-10,ATL,CONST(REF(ATL,BC2和TC2的较小值-11)))
RL赋值:IF(CURRBARSCOUNT>=BC2和TC2的较小值-10,UTL,CONST(REF(UTL,BC2和TC2的较小值-11)))
上轨赋值:IF(NP>FP,IF(ATL<=RH,ATL,DRAWNULL),IF(ATL>=RL,ATL,DRAWNULL)), 画蓝色, 线宽为2
下轨赋值:IF(NP>FP,IF(UTL<=RH,UTL,DRAWNULL),IF(UTL>=RL,UTL,DRAWNULL)),画洋红色 , 线宽为2
操作2赋值:(C*4+L*3+H*2+O)/10,画绿色,LINETHICK1
P赋值:14
A1Z赋值:P日前的操作2=2*P+1日内操作2最高值
B1赋值:A1Z的P过滤
C1Z:=BACKSET(B1,P+1)
D1赋值:C1Z的P过滤
{高点}
A2Z赋值:P日前的操作2=2*P+1日内操作2最低值
B2赋值:A2Z的P过滤
C2Z赋值:BACKSET(B2,P+1)
D2赋值:C2Z的P过滤
{低点}
下赋值:REF(操作2,上次D2距今天数),COLOR00FF00,NODRAW
上赋值:REF(操作2,上次D1距今天数),COLORFF00FF,NODRAW
STICKLINE(1日前的操作2=下 AND 操作2>下轨,L,L-0.3,3,0),COLORGRAY
STICKLINE(1日前的操作2=下 AND 操作2>下轨,L-0.05,L-0.25,2,0),画绿色
DRAWTEXT(1日前的操作2=下 AND 操作2>下轨,L-0.4,'绿灯')画绿色
当满足条件操作2=上时,在H和H+0.3之间画柱状线
当满足条件操作2=上时,在H+0.05和H+0.25之间画柱状线
当满足条件操作2=上时,在H+0.4和'红灯'位置书写文字
输出
Z:ZIG(3,上),COLORFFFFFF
LC赋值:1日前的收盘价
RSI5赋值:((SMA(MAX((收盘价 - LC),0),5,1) / SMA((收盘价 - LC的绝对值),5,1)) * 100)
TR1赋值:SUM(MAX(MAX((最高价 - 最低价),(最高价 - 1日前的收盘价的绝对值)),ABS((最低价 - 1日前的收盘价))),10)
HD赋值:(最高价 - 1日前的最高价)
LD赋值:(1日前的最低价 - 最低价)
DMP赋值:SUM(IF(((HD > 0) AND (HD > LD)),HD,0),10)
DMM赋值:SUM(IF(((LD > 0) AND (LD > HD)),LD,0),10)
PDI:=((DMP * 100) / TR1)
MDI赋值:((DMM * 100) / TR1)
ADX:=MA((((MDI - PDI的绝对值) / (MDI + PDI)) * 100),5)
AV赋值:(RSI5 + ADX)
WR10赋值:((100 *( 10日内最高价最高值 - 收盘价)) / (10日内最高价最高值 - 10日内最低价最低值))
NEWVOL赋值:(RSI5 - WR10)
回调买赋值:(AV + NEW成交量)
DRAWTEXT(回调买上穿0,L*0.86,'↖回调买'),画黄色
MT1赋值:IF(ISLASTBAR,REF((C*2-REF(C,3)),1),DRAWNULL)
MT2赋值:IF(ISLASTBAR,REF((C*2-REF(C,3)),2),DRAWNULL)
MT3赋值:IF(ISLASTBAR,C*2-3日前的C,DRAWNULL)
当满足条件ISLASTBAR时,在MT2和' ●'位置书写文字
当满足条件ISLASTBAR时,在MT1和' ●'位置书写文字
当满足条件ISLASTBAR时,在MT3和' ●'位置书写文字