通达信主趋势MACD副图
DIF:EMA(CLOSE,12)-EMA(CLOSE,26),COLORGREEN;DEA:EMA(DIF,9),COLORBLUE;MACD:(DIF-DEA)*2,COLORSTICK;IF(DIF>REF(DIF,1),DIF,DRAWNULL),COLORRED,LINETHICK2;IF(DEA>REF(DEA,1),DEA,DRAWNULL),COLORRED,LINETHICK2;STICKLINE(((MACD<REF(MACD,1)) AND (MACD>0)),0,MACD,0.05,0),COLORLIBLUE,LINETHICK2;STICKLINE(((MACD>REF(MACD,1)) AND (MACD<0)),0,MACD,0.05,0),COLORFF00FF,LINETHICK2;
NH:=REF(DIF,3)>=REF(DIF,2) AND REF(DIF,2)>=REF(DIF,1) AND DIF>REF(DIF,1)*1.1;NH1:=ABS((REF(DIF,1)-REF(DEA,1))/REF(DIF,1))<=0.2;DT:=REF(DIF,2)>REF(DEA,2) AND REF(DIF,1)>=REF(DEA,1) AND DIF>DEA;NLZ:=MACD>REF(MACD,1) AND DIF>0;NLZ1:=MACD>REF(MACD,1) AND DIF<0;将死不死1:=(NH1 AND NH AND DT AND NLZ);将死不死0:=(NH1 AND NH AND DT AND NLZ1);将死不死:将死不死1 OR 将死不死0,NODRAW;DRAWICON(将死不死,DEA-0.01,38);DRAWICON(将死不死,DEA-0.03,38);DRAWICON(CROSS(DIF,DEA),DEA,9);DRAWICON(CROSS(DEA,DIF),DIF,15);AB1:=BARSLAST(REF(CROSS(DIF,DEA),1));底背离:=REF(CLOSE,AB1+1)>CLOSE AND DIF>REF(DIF,AB1+1) AND CROSS(DIF,DEA);DRAWLINE(AB1=0,DEA,底背离,DEA,0),COLORYELLOW,LINETHICK1;AB2:=BARSLAST(REF(CROSS(DEA,DIF),1));顶背离:=REF(CLOSE,AB2+1)<CLOSE AND REF(DEA,AB2+1)>DEA AND CROSS(DEA,DIF);DRAWLINE(AB2=0,DEA,顶背离,DEA,0),COLORGREEN,LINETHICK1;DRAWTEXT(底背离>0,DEA,'底背离'),COLORYELLOW;DRAWTEXT(顶背离>0,DEA,'顶背离'),COLORGREEN;VA:=IF(CLOSE>REF(CLOSE,1),VOL,-VOL);OBV1:=SUM(IF(CLOSE=REF(CLOSE,1),0,VA),0);OBV2:=EMA(OBV1,3)-MA(OBV1,9);OBV3:=EMA(IF(OBV2>0,OBV2,0),3);MAC3:=MA(C,3);SHORT:=12;LONG:=26;MID:=9;STICKLINE(OBV3>REF(OBV3,1) AND MAC3>REF(MAC3,1),0,MACD,2,0),COLORYELLOW;{持币:STICKLINE((SAR(10,2,20)>=H),MACD,0,1.5,0),COLORGREEN;持股:STICKLINE((SAR(10,2,20)<=L),0,MACD,1.5,0),COLORYELLOW;}
ZSC:=CROSS(DEA#WEEK,DIF#WEEK);ZSC1:=CROSS(DEA,DIF);PC:=IF(EXISTR(ZSC,7,1),0,1);PC1:=IF(EXISTR(ZSC1,7,1),0,1);Q1:=MACD<0 AND MACD>REF(MACD ,1) ANDREF(MACD ,1)<REF(MACD ,2) AND REF(MACD ,2)<REF(MACD ,3)AND REF(MACD ,3)<REF(MACD ,4);SCL:=EXISTR(CROSS(DEA,DIF),9,1);C1:=BARSLAST(REF(Q1,1));C2:=REF(MACD,C1+1)<MACD AND Q1 AND DIF<0 ;TJ:=MACD>0;T:=MACD<0;A:=LLV(MACD,50)=MACD;DRAWICON(A AND FILTERX(A,20), MACD,1);DRAWTEXT(BARSLAST(TJ)=1,MACD,'1'),COLORYELLOW;DRAWTEXT(BARSLAST(TJ)=2,MACD,'2'),COLORYELLOW;DRAWTEXT(BARSLAST(TJ)=3,MACD,'3'),COLORYELLOW;DRAWTEXT(BARSLAST(TJ)=5,MACD,'5'),COLORYELLOW;DRAWTEXT(BARSLAST(TJ)=8,MACD,'8'),COLORYELLOW;DRAWTEXT(BARSLAST(TJ)=13,MACD,'13'),COLORYELLOW;DRAWTEXT(BARSLAST(TJ)=21,MACD,'21'),COLORYELLOW;DRAWTEXT(BARSLAST(TJ)=34,MACD,'34'),COLORYELLOW;DRAWTEXT(BARSLAST(TJ)=55,MACD,'55'),COLORYELLOW;DRAWTEXT(BARSLAST(T)=1,MACD,'1'),COLORGREEN;DRAWTEXT(BARSLAST(T)=2,MACD,'2'),COLORGREEN;DRAWTEXT(BARSLAST(T)=3,MACD,'3'),COLORGREEN;DRAWTEXT(BARSLAST(T)=5,MACD,'5'),COLORGREEN;DRAWTEXT(BARSLAST(T)=8,MACD,'8'),COLORGREEN;DRAWTEXT(BARSLAST(T)=13,MACD,'13'),COLORGREEN;DRAWTEXT(BARSLAST(T)=21,MACD,'21'),COLORGREEN;DRAWTEXT(BARSLAST(T)=34,MACD,'34'),COLORGREEN;DRAWTEXT(BARSLAST(T)=55,MACD,'55'),COLORGREEN;
X_1:=(CLOSE-EMA(CLOSE,5))/EMA(CLOSE,5)*100;X_2:=(CLOSE-EMA(CLOSE,10))/EMA(CLOSE,10)*100;X_3:=(CLOSE-EMA(CLOSE,20))/EMA(CLOSE,20)*100;X_4:=(CLOSE-EMA(CLOSE,60))/EMA(CLOSE,60)*100;X_5:=(CLOSE-EMA(CLOSE,120))/EMA(CLOSE,120)*100;X_6:=X_1>1 AND X_2>2 AND X_3>3 AND X_4>4;X_7:=X_1>2 AND X_2>4 AND X_3>6 AND X_4>8;X_8:=X_1>3 AND X_2>5 AND X_3>7 AND X_4>9;X_9:=X_1>4 AND X_2>6 AND X_3>8 AND X_4>10 AND X_5>12;X_10:=BARSLASTCOUNT(X_7)=1 AND CROSS(CLOSE,EMA(CLOSE,50)*1.19) AND HIGH/CLOSE<1.05;{指标众筹QQ 115534139}小鱼:BARSLASTCOUNT(X_6),NODRAW,COLORWHITE;红鱼:BARSLASTCOUNT(X_7),NODRAW,COLORRED;紫鱼:BARSLASTCOUNT(X_8),NODRAW,COLORMAGENTA;黄鱼:BARSLASTCOUNT(X_9),NODRAW,COLORYELLOW;
未来函数检测结果如下:
该公式包含未来函数:#WEEK
解密、编写股票、期货策略请联系QQ或微信同号:88652583
相关股票指标公式
原理解析:
输出DIF:收盘价的12日指数移动平均-收盘价的26日指数移动平均,画绿色
输出DEA:DIF的9日指数移动平均, 画蓝色
输出MACD:(DIF-DEA)*2,COLORSTICK
IF(DIF>1日前的DIF,DIF,DRAWNULL),画红色,LINETHICK2
IF(DEA>1日前的DEA,DEA,DRAWNULL),画红色,LINETHICK2
STICKLINE(((MACD<1日前的MACD) AND (MACD>0)),0,MACD,0.05,0),COLORLIBLUE,LINETHICK2
STICKLINE(((MACD>1日前的MACD) AND (MACD<0)),0,MACD,0.05,0),COLORFF00FF,LINETHICK2
NH赋值:3日前的DIF>=2日前的DIF AND 2日前的DIF>=1日前的DIF AND DIF>1日前的DIF*1.1
NH1:=(1日前的DIF-1日前的DEA的绝对值/1日前的DIF)<=0.2
DT赋值:2日前的DIF>2日前的DEA AND 1日前的DIF>=1日前的DEA AND DIF>DEA
NLZ赋值:MACD>1日前的MACD AND DIF>0
NLZ1:=MACD>1日前的MACD AND DIF<0
将死不死1赋值:(NH1 AND NH AND DT AND NLZ)
将死不死0赋值:(NH1 AND NH AND DT AND NLZ1)
输出将死不死:将死不死1 OR 将死不死0,NODRAW
当满足条件将死不死时,在DEA-0.01和38之间画图标
当满足条件将死不死时,在DEA-0.03和38之间画图标
DRAWICON(DIF上穿DEA,DEA,9)
DRAWICON(DEA上穿DIF,DIF,15)
AB1赋值:上次1日前的DIF上穿DEA距今天数
底背离赋值:AB1+1日前的收盘价>收盘价 AND DIF>AB1+1日前的DIF AND DIF上穿DEA
DRAWLINE(AB1=0,DEA,底背离,DEA,0),画黄色,LINETHICK1
AB2赋值:上次1日前的DEA上穿DIF距今天数
顶背离赋值:AB2+1日前的收盘价<收盘价 AND AB2+1日前的DEA>DEA AND DEA上穿DIF
DRAWLINE(AB2=0,DEA,顶背离,DEA,0),画绿色,LINETHICK1
当满足条件底背离>0时,在DEA和'底背离'位置书写文字
当满足条件顶背离>0时,在DEA和'顶背离'位置书写文字
VA赋值:IF(收盘价>1日前的收盘价,成交量,-成交量)
OBV1赋值:SUM(IF(收盘价=1日前的收盘价,0,VA),0)
OBV2赋值:OBV1的3日指数移动平均-OBV1的9日简单移动平均
如果OBV2>0返回OBV2否则返回0
MAC3赋值:C的3日简单移动平均
SHORT赋值:12
LONG赋值:26
MID赋值:9
STICKLINE(OBV3>1日前的OBV3 AND MAC3>1日前的MAC3,0,MACD,2,0),画黄色
输出{持币:STICKLINE((SAR(10,2,20)>=H),MACD,0,1.5,0),画绿色
输出持股:STICKLINE((SAR(10,2,20)<=L),0,MACD,1.5,0),画黄色
}ZSC赋值:DEA#WEEK上穿DIF#WEEK
ZSC1赋值:DEA上穿DIF
PC赋值:IF(EXISTR(ZSC,7,1),0,1)
PC1:=IF(EXISTR(ZSC1,7,1),0,1)
Q1赋值:MACD<0 AND MACD>1日前的MACD AND1日前的MACD <2日前的MACD AND 2日前的MACD <3日前的MACD AND 3日前的MACD <4日前的MACD
SCL赋值:EXISTR(DEA上穿DIF,9,1)
C1赋值:上次1日前的Q1距今天数
C2赋值:C1+1日前的MACDTJ赋值:MACD>0
T赋值:MACD<0
A赋值:50日内MACD最低值=MACD
DRAWICON(A AND FILTERX(A,20), MACD,1)
DRAWTEXT(上次TJ距今天数=1,MACD,'1'),画黄色
DRAWTEXT(上次TJ距今天数=2,MACD,'2'),画黄色
DRAWTEXT(上次TJ距今天数=3,MACD,'3'),画黄色
DRAWTEXT(上次TJ距今天数=5,MACD,'5'),画黄色
DRAWTEXT(上次TJ距今天数=8,MACD,'8'),画黄色
DRAWTEXT(上次TJ距今天数=13,MACD,'13'),画黄色
DRAWTEXT(上次TJ距今天数=21,MACD,'21'),画黄色
DRAWTEXT(上次TJ距今天数=34,MACD,'34'),画黄色
DRAWTEXT(上次TJ距今天数=55,MACD,'55'),画黄色
DRAWTEXT(上次T距今天数=1,MACD,'1'),画绿色
DRAWTEXT(上次T距今天数=2,MACD,'2'),画绿色
DRAWTEXT(上次T距今天数=3,MACD,'3'),画绿色
DRAWTEXT(上次T距今天数=5,MACD,'5'),画绿色
DRAWTEXT(上次T距今天数=8,MACD,'8'),画绿色
DRAWTEXT(上次T距今天数=13,MACD,'13'),画绿色
DRAWTEXT(上次T距今天数=21,MACD,'21'),画绿色
DRAWTEXT(上次T距今天数=34,MACD,'34'),画绿色
DRAWTEXT(上次T距今天数=55,MACD,'55'),画绿色
X_1赋值:(收盘价-收盘价的5日指数移动平均)/收盘价的5日指数移动平均*100
X_2赋值:(收盘价-收盘价的10日指数移动平均)/收盘价的10日指数移动平均*100
X_3赋值:(收盘价-收盘价的20日指数移动平均)/收盘价的20日指数移动平均*100
X_4赋值:(收盘价-收盘价的60日指数移动平均)/收盘价的60日指数移动平均*100
X_5赋值:(收盘价-收盘价的120日指数移动平均)/收盘价的120日指数移动平均*100
X_6赋值:X_1>1 AND X_2>2 AND X_3>3 AND X_4>4
X_7赋值:X_1>2 AND X_2>4 AND X_3>6 AND X_4>8
X_8赋值:X_1>3 AND X_2>5 AND X_3>7 AND X_4>9
X_9赋值:X_1>4 AND X_2>6 AND X_3>8 AND X_4>10 AND X_5>12
X_10:=BARSLASTCOUNT(X_7)=1 AND CROSS(收盘价,收盘价的50日指数移动平均*1.19) AND 最高价/收盘价<1.05
输出{指标众筹QQ 115534139}小鱼:BARSLASTCOUNT(X_6),NODRAW,COLORWHITE
输出红鱼:BARSLASTCOUNT(X_7),NODRAW,画红色
输出紫鱼:BARSLASTCOUNT(X_8),NODRAW,COLORMAGENTA
输出黄鱼:BARSLASTCOUNT(X_9),NODRAW,画黄色