通达信自用仓位控制顶底操盘主图指标 源码
K:=1;
P:=6;
EM:=1;
M1:=5;
M2:=10;
M3:=20;
M4:=60;
DRAWTEXT_FIX(1,0.01,0.02,0,EXTERNSTR(0,1)),COLORGREEN;
DRAWGBK(C>0,RGB(0,0,0),RGB(00,0,0),0,'EM',0);
DRAWKLINE(H,O,L,C);
K1:=REF(C,1)=DYNAINFO(3) AND O=DYNAINFO(4) AND C=DYNAINFO(7) AND H=DYNAINFO(5) AND L=DYNAINFO(6);
K2:=BARSLAST(V=HHV(V,20));
K3:=BACKSET(K1,K2+1);
STICKLINE(K2=0 AND K3=1,H,H*1.003,8*EM,0),COLORYELLOW;
收:C,NODRAW;
DRAWTEXT(EM=1&&K2=0&&K3=1,H*1.02,'20天内最高量的'),COLORGREEN;
DRAWTEXT(EM=1&&K2=0&&K3=1,H*0.98,'当天最高价划线'),COLORGREEN;
爆发点:=(DCLOSE-REF(C,1))/REF(C,1)*100;
XB:=CROSS(爆发点,20);
DRAWTEXT(XB,L,'量价齐升'),COLORRED;
PL5:=ZIG(3,5);
EN1:=ZIG(3,5)>REF(ZIG(3,5),1) AND REF(ZIG(3,5),1)<=REF(ZIG(3,5),2) AND REF(ZIG(3,5),2)<=REF(ZIG(3,5),3);
EX1:=ZIG(3,5)=REF(ZIG(3,5),2) AND REF(ZIG(3,5),2)>=REF(ZIG(3,5),3);
PL10:=ZIG(3,10);
EN2:=ZIG(3,10)>REF(ZIG(3,10),1) AND REF(ZIG(3,10),1)<=REF(ZIG(3,10),2) AND REF(ZIG(3,10),2)<=REF(ZIG(3,10),3);
EX2:=ZIG(3,10)=REF(ZIG(3,10),2) AND REF(ZIG(3,10),2)>=REF(ZIG(3,10),3);
PL20:=ZIG(3,20);
EN3:=ZIG(3,20)>REF(ZIG(3,20),1) AND REF(ZIG(3,20),1)<=REF(ZIG(3,20),2) AND REF(ZIG(3,20),2)<=REF(ZIG(3,20),3);
EX3:=ZIG(3,20)=REF(ZIG(3,20),2) AND REF(ZIG(3,20),2)>=REF(ZIG(3,20),3);
PL40:=ZIG(3,40);
走强1:=BARSLAST(PL5< REF(PL5,1));
走弱1:=BARSLAST(PL5>REF(PL5,1));
走强2:=BARSLAST(PL10< REF(PL10,1));
走弱2:=BARSLAST(PL10>REF(PL10,1));
走强3:=BARSLAST(PL20< REF(PL20,1));
走弱3:=BARSLAST(PL20>REF(PL20,1));
ZTJZ5:=IF(PL10>REF(PL10,1),COUNT(EN1,走强2),0);
ZTJD5:=IF(PL10>REF(PL10,1),COUNT(EX1,走强2),0);
DTJZ5:=IF(PL10< REF(PL10,1),COUNT(EN1,走弱2),0);
DTJD5:=IF(PL10< REF(PL10,1),COUNT(EX1,走弱2),0);
ZTJZ10:=IF(PL20>REF(PL20,1),COUNT(EN2,走强3),0);
ZTJD10:=IF(PL20>REF(PL20,1),COUNT(EX2,走强3),0);
DTJZ10:=IF(PL20< REF(PL20,1),COUNT(EN2,走弱3),0);
DTJD10:=IF(PL20< REF(PL20,1),COUNT(EX2,走弱3),0);
DRAWTEXT(EN1 AND DTJZ5=1,L*0.98,'反弹'),COLORFFFF00;
DRAWTEXT(EX1 AND DTJD5=2,H*1.02,'清仓'),COLORGREEN;
DRAWTEXT(EN2 AND ZTJZ5=1,L*0.98,'买入'),COLORLIRED;
DRAWTEXT(EX1 AND PL10>REF(PL10,1) AND ZTJD5=1,H*1.02,'留1成仓'),COLORLIGREEN;
DRAWTEXT(EN1 AND PL10>REF(PL10,1) AND ZTJZ5=2,L*0.98,'加半仓'),COLOR0000FF;
DRAWTEXT(EX1 AND PL10>REF(PL10,1) AND ZTJZ5=2,H*1.02,'减7成'),COLORGREEN;
DRAWTEXT(EN1 AND PL10>REF(PL10,1) AND ZTJZ5=3,L*0.98,'加7成'),COLOR0000FF;
DRAWTEXT(EX2 AND PL20>REF(PL20,1) AND ZTJD10=1,H*1.02,'逢高出局'),COLORLIBLUE;
DRAWTEXT(EN2 AND DTJZ10=1,L*0.94,'等待主升'),COLORWHITE;
DRAWTEXT(EN3 AND ZTJZ10=1,L*0.94,'满仓进场'),COLORMAGENTA;
DRAWTEXT(EX2 AND PL20>REF(PL20,1) AND ZTJD10=1,H*1.06,'卖'),COLORLICYAN;
DRAWTEXT(EN2 AND PL20>REF(PL20,1) AND ZTJZ10=2,L*0.94,'满仓持股'),COLORLIRED;
DRAWTEXT(EX2 AND PL20>REF(PL20,1) AND ZTJD10=2 OR (ZTJD10=0 OR ZTJD10=2) AND EX2,H*1.06,'需要清仓'),COLORCYAN;
DRAWTEXT(EN2 AND PL20>REF(PL20,1) AND ZTJZ10=3,L*0.94,'开始大涨'),LINETHICK3,COLOR00FFFF;
MA1:MA(CLOSE,M1);
MA2:MA(CLOSE,M2);
MA3:MA(CLOSE,M3);
MA4:MA(CLOSE,M4);
DIF:=EMA(DCLOSE,12)-EMA(DCLOSE,26);
DEA:=EMA(DIF,9);
AAA:=(DIF-DEA)*2*60;
起爆:=CROSS(AAA-REF(AAA,1),15),COLORRED,LINETHICK2;
DRAWTEXT(起爆,L*0.99,'↖暴涨'),COLORYELLOW,LINETHICK2;
DRAWTEXT(C>REF(C,1)*1.093 ,H,'板'),COLORGREEN,DRAWABOVE;
DRAWTEXT(C>REF(C,1)*1.093 AND C>MA(C,60) AND C< MA(C,60)*1.15 ,L,'★板买'),COLORRED;
T1B:=CONST(LLVBARS(LOW,10));
T1HIGH:=CONST(REF(HIGH,T1B));
CC:=CONST(CURRBARSCOUNT);
T2B:=CONST(BARSLAST(CURRBARSCOUNT>CC+T1B AND H>T1HIGH));
T2HIGH:=CONST(REF(HIGH,T2B));
T3:=CONST(BARSLAST(CURRBARSCOUNT>CC+T2B AND HIGH>T2HIGH));
T3HIGH:=CONST(REF(HIGH,T3));
涨停线:DRAWLINE(CURRBARSCOUNT=T3+1,T3HIGH, ISLASTBAR, T3HIGH, 1),COLORGREEN,LINETHICK2;
C2:=REF(C,1);
涨停:=IF((C-C2)*100/C2>=(10-0.01*100/C2),1,0);
STICKLINE(涨停,OPEN,CLOSE,2,0),,COLORYELLOW;
STICKLINE(涨停,H,L,0,0),,COLORYELLOW;
跌停:=IF((C2-C)*100/C2>=(10-0.01*100/C2),1,0);
STICKLINE(跌停,OPEN,CLOSE,2,0),COLORGREEN;
STICKLINE(跌停,H,L,0,1),COLORGREEN;
N:=10;
HH:IF(CURRBARSCOUNT<=N,CONST(HHV(H,N)),DRAWNULL),COLORGREEN;
LL:IF(CURRBARSCOUNT<=N,CONST(LLV(L,N)),DRAWNULL),COLORRED;
DRAWNUMBER(CURRBARSCOUNT=N,HH,HH),COLORGREEN;
DRAWNUMBER(CURRBARSCOUNT=N,LL,LL),COLORRED;
DRAWICON(CURRBARSCOUNT=N,L,1);
DRAWTEXT(CURRBARSCOUNT=N,HH*1.04,STRCAT('振幅:',CON2STR((HH-LL)/LL*100,2))),COLORYELLOW;
DRAWTEXT_FIX(ISLASTBAR,0.01,0.99,0,EXTERNSTR(0,3)),COLORYELLOW;
DRAWTEXT(CROSS(ZIG(3,8),REF(ZIG(3,8),1)),LOW*0.94,'底') ,LINETHICK2,COLORYELLOW;
DRAWTEXT(CROSS(REF(ZIG(3,7),1),ZIG(3,7)),HIGH*1.04,'顶') ,LINETHICK2,COLORGREEN;
庄线A:=(3*CLOSE+OPEN+LOW+HIGH)/6;
庄线B:(19*庄线A+19*REF(庄线A,1)+18*REF(庄线A,2)+17*REF(庄线A,3)+16*REF(庄线A,4)+15*REF(庄线A,5)+14*REF(庄线A,6)+13*REF(庄线A,7)+12*REF(庄线A,8)+11*REF(庄线A,9)+10*REF(庄线A,10)+9*REF(庄线A,11)+8*REF(庄线A,12)+7*REF(庄线A,13)+6*REF(庄线A,14)+5*REF(庄线A,15)+4*REF(庄线A,16)+3*REF(庄线A,17)+2*REF(庄线A,20)+REF(庄线A,19))/210,COLOR000000;
庄线支撑:MA(庄线B,5),COLORRED,LINETHICK3;
天数:=BARSLAST(涨停);
DRAWTEXT(BETWEEN(天数,1,10), H*1.02, VAR2STR(天数,0));
未来函数检测结果如下:
该公式包含未来函数:ZIG
该公式包含未来函数:BACKSET
该公式包含未来函数:DYNAINFO
该公式包含未来函数:DCLOSE
解密、编写股票、期货策略请联系QQ或微信同号:88652583
相关股票指标公式
原理解析:
K赋值:1
P赋值:6
EM赋值:1
M1赋值:5
M2赋值:10
M3赋值:20
M4赋值:60
DRAWTEXT_FIX(1,0.01,0.02,0,EXTERNSTR(0,1)),COLORGREEN
DRAWGBK(C>0,RGB(0,0,0),RGB(00,0,0),0,'EM',0)
DRAWKLINE(H,O,L,C)
K1:=1日前的C=DYNAINFO(3) AND O=DYNAINFO(4) AND C=DYNAINFO(7) AND H=DYNAINFO(5) AND L=DYNAINFO(6)
K2:=上次V=20日内V最高值距今天数
K3:=BACKSET(K1,K2+1)
当满足条件K2=0 AND K3=1时,在H和H*1.003之间画柱状线
输出收:C,NODRAW
当满足条件EM=1&&K2=0&&K3=1时,在H*1.02和'20天内最高量的'位置书写文字
当满足条件EM=1&&K2=0&&K3=1时,在H*0.98和'当天最高价划线'位置书写文字
爆发点赋值:(D收盘价-1日前的C)/1日前的C*100
XB赋值:爆发点上穿20
当满足条件XB时,在L和'量价齐升'位置书写文字
PL5:=ZIG(3,5)
EN1赋值:ZIG(3,5)>REF(ZIG(3,5),1) AND REF(ZIG(3,5),1)<=REF(ZIG(3,5),2) AND REF(ZIG(3,5),2)<=REF(ZIG(3,5),3)
EX1赋值:ZIG(3,5)=REF(ZIG(3,5),2) AND REF(ZIG(3,5),2)>=REF(ZIG(3,5),3)
PL10:=ZIG(3,10)
EN2赋值:ZIG(3,10)>REF(ZIG(3,10),1) AND REF(ZIG(3,10),1)<=REF(ZIG(3,10),2) AND REF(ZIG(3,10),2)<=REF(ZIG(3,10),3)
EX2赋值:ZIG(3,10)=REF(ZIG(3,10),2) AND REF(ZIG(3,10),2)>=REF(ZIG(3,10),3)
PL20:=ZIG(3,20)
EN3赋值:ZIG(3,20)>REF(ZIG(3,20),1) AND REF(ZIG(3,20),1)<=REF(ZIG(3,20),2) AND REF(ZIG(3,20),2)<=REF(ZIG(3,20),3)
EX3赋值:ZIG(3,20)=REF(ZIG(3,20),2) AND REF(ZIG(3,20),2)>=REF(ZIG(3,20),3)
PL40:=ZIG(3,40)
走强1赋值:上次PL5< 1日前的PL5距今天数
走弱1赋值:上次PL5>1日前的PL5距今天数
走强2赋值:上次PL10< 1日前的PL10距今天数
走弱2赋值:上次PL10>1日前的PL10距今天数
走强3赋值:上次PL20< 1日前的PL20距今天数
走弱3赋值:上次PL20>1日前的PL20距今天数
ZTJZ5赋值:IF(PL10>1日前的PL10,统计走强2日满足EN1的天数,0)
ZTJD5赋值:IF(PL10>1日前的PL10,统计走强2日满足EX1的天数,0)
DTJZ5赋值:IF(PL10< 1日前的PL10,统计走弱2日满足EN1的天数,0)
DTJD5赋值:IF(PL10< 1日前的PL10,统计走弱2日满足EX1的天数,0)
ZTJZ10赋值:IF(PL20>1日前的PL20,统计走强3日满足EN2的天数,0)
ZTJD10赋值:IF(PL20>1日前的PL20,统计走强3日满足EX2的天数,0)
DTJZ10赋值:IF(PL20< 1日前的PL20,统计走弱3日满足EN2的天数,0)
DTJD10赋值:IF(PL20< 1日前的PL20,统计走弱3日满足EX2的天数,0)
当满足条件EN1 AND DTJZ5=1时,在L*0.98和'反弹'位置书写文字
当满足条件EX1 AND DTJD5=2时,在H*1.02和'清仓'位置书写文字
当满足条件EN2 AND ZTJZ5=1时,在L*0.98和'买入'位置书写文字
DRAWTEXT(EX1 AND PL10>1日前的PL10 AND ZTJD5=1,H*1.02,'留1成仓'),COLORLIGREEN
DRAWTEXT(EN1 AND PL10>1日前的PL10 AND ZTJZ5=2,L*0.98,'加半仓'),COLOR0000FF
DRAWTEXT(EX1 AND PL10>1日前的PL10 AND ZTJZ5=2,H*1.02,'减7成'),COLORGREEN
DRAWTEXT(EN1 AND PL10>1日前的PL10 AND ZTJZ5=3,L*0.98,'加7成'),COLOR0000FF
DRAWTEXT(EX2 AND PL20>1日前的PL20 AND ZTJD10=1,H*1.02,'逢高出局'),COLORLIBLUE
当满足条件EN2 AND DTJZ10=1时,在L*0.94和'等待主升'位置书写文字
当满足条件EN3 AND ZTJZ10=1时,在L*0.94和'满仓进场'位置书写文字
DRAWTEXT(EX2 AND PL20>1日前的PL20 AND ZTJD10=1,H*1.06,'卖'),COLORLICYAN
DRAWTEXT(EN2 AND PL20>1日前的PL20 AND ZTJZ10=2,L*0.94,'满仓持股'),COLORLIRED
DRAWTEXT(EX2 AND PL20>1日前的PL20 AND ZTJD10=2 OR (ZTJD10=0 OR ZTJD10=2) AND EX2,H*1.06,'需要清仓'),COLORCYAN
DRAWTEXT(EN2 AND PL20>1日前的PL20 AND ZTJZ10=3,L*0.94,'开始大涨'),LINETHICK3,COLOR00FFFF
输出MA1:收盘价的M1日简单移动平均
输出MA2:收盘价的M2日简单移动平均
输出MA3:收盘价的M3日简单移动平均
输出MA4:收盘价的M4日简单移动平均
DIF赋值:D收盘价的12日指数移动平均-D收盘价的26日指数移动平均
DEA赋值:DIF的9日指数移动平均
AAA赋值:(DIF-DEA)*2*60
起爆赋值:CROSS(AAA-1日前的AAA,15),画红色,LINETHICK2
当满足条件起爆时,在L*0.99和'↖暴涨'位置书写文字
DRAWTEXT(C>1日前的C*1.093 ,H,'板'),COLORGREEN,DRAWABOVE
DRAWTEXT(C>1日前的C*1.093 AND C>C的60日简单移动平均 AND C< C的60日简单移动平均*1.15 ,L,'★板买'),画红色
T1B赋值:CONST(LLVBARS(最低价,10))
T1HIGH赋值:CONST(T1B日前的最高价)
CC赋值:CONST(CURRBARSCOUNT)
T2B赋值:CONST(上次CURRBARSCOUNT>CC+T1B AND H>T1HIGH距今天数)
T2HIGH赋值:CONST(T2B日前的最高价)
T3赋值:CONST(上次CURRBARSCOUNT>CC+T2B AND 最高价>T2HIGH距今天数)
T3最高价:=CONST(T3日前的最高价)
输出涨停线:DRAWLINE(CURRBARSCOUNT=T3+1,T3最高价, ISLASTBAR, T3最高价, 1),COLORGREEN,LINETHICK2
C2赋值:1日前的C
涨停赋值:IF((C-C2)*100/C2>=(10-0.01*100/C2),1,0)
当满足条件涨停时,在OPEN和收盘价之间画柱状线
当满足条件涨停时,在H和L之间画柱状线
跌停赋值:IF((C2-C)*100/C2>=(10-0.01*100/C2),1,0)
当满足条件跌停时,在OPEN和收盘价之间画柱状线
当满足条件跌停时,在H和L之间画柱状线
N赋值:10
输出HH:IF(CURRBARSCOUNT<=N,CONST(N日内H最高值),DRAWNULL),COLORGREEN
输出LL:IF(CURRBARSCOUNT<=N,CONST(N日内L最低值),DRAWNULL),画红色
DRAWNUMBER(CURRBARSCOUNT=N,HH,HH),COLORGREEN
DRAWNUMBER(CURRBARSCOUNT=N,LL,LL),画红色
当满足条件CURRBARSCOUNT=N时,在L和1之间画图标
DRAWTEXT(CURRBARSCOUNT=N,HH*1.04,STRCAT('振幅:',CON2STR((HH-LL)/LL*100,2))),COLORYELLOW
DRAWTEXT_FIX(ISLASTBAR,0.01,0.99,0,EXTERNSTR(0,3)),COLORYELLOW
DRAWTEXT(CROSS(ZIG(3,8),REF(ZIG(3,8),1)),最低价*0.94,'底') ,LINETHICK2,COLORYELLOW
DRAWTEXT(CROSS(REF(ZIG(3,7),1),ZIG(3,7)),最高价*1.04,'顶') ,LINETHICK2,COLORGREEN
庄线A赋值:(3*收盘价+OPEN+最低价+最高价)/6
输出庄线B:(19*庄线A+19*1日前的庄线A+18*2日前的庄线A+17*3日前的庄线A+16*4日前的庄线A+15*5日前的庄线A+14*6日前的庄线A+13*7日前的庄线A+12*8日前的庄线A+11*9日前的庄线A+10*10日前的庄线A+9*11日前的庄线A+8*12日前的庄线A+7*13日前的庄线A+6*14日前的庄线A+5*15日前的庄线A+4*16日前的庄线A+3*17日前的庄线A+2*20日前的庄线A+19日前的庄线A)/210,COLOR000000
输出庄线支撑:庄线B的5日简单移动平均,画红色,LINETHICK3
天数赋值:上次涨停距今天数
DRAWTEXT(BETWEEN(天数,1,10), H*1.02, VAR2STR(天数,0))