MACD面积加斐波那契数列
2016-7-6 12:01:24点击:
{通达信MACD面积加斐波那契数列副图指标}
SHORT:=12;
LONG:=26;
MID:=9;
DIF:EMA(CLOSE,SHORT)-EMA(CLOSE,LONG);
DEA:EMA(DIF,MID);
MACD:(DIF-DEA)*2,COLORSTICK;
{HTTP://WWW.88GS.COM}
{标注斐波那契数字}
TJ:=MACD>0;
T:=MACD<0;
A:=LLV(MACD,50)=MACD;
DRAWICON(A AND FILTERX(A,20), MACD,0);
DRAWTEXT(BARSLAST(TJ)=1,MACD-0.2,'1'),COLORYELLOW;
{DRAWTEXT(BARSLAST(TJ)=2,MACD-0.1,'2'),COLORYELLOW;}
DRAWTEXT(BARSLAST(TJ)=3,MACD-0.09,'3'),COLORYELLOW;
DRAWTEXT(BARSLAST(TJ)=5,MACD-0.09,'5'),COLORYELLOW;
DRAWTEXT(BARSLAST(TJ)=8,MACD-0.08,'8'),COLORYELLOW;
DRAWTEXT(BARSLAST(TJ)=13,MACD-0.08,'13'),COLORYELLOW;
DRAWTEXT(BARSLAST(TJ)=18,MACD-0.08,'18'),COLORYELLOW;
DRAWTEXT(BARSLAST(TJ)=21,MACD-0.08,'21'),COLORYELLOW;
DRAWTEXT(BARSLAST(TJ)=29,MACD-0.08,'29'),COLORYELLOW;
DRAWTEXT(BARSLAST(TJ)=34,MACD-0.08,'34'),COLORYELLOW;
DRAWTEXT(BARSLAST(TJ)=55,MACD-0.08,'55'),COLORYELLOW;
DRAWTEXT(BARSLAST(TJ)=89,MACD-0.08,'89'),COLORYELLOW;
DRAWTEXT(BARSLAST(TJ)=144,MACD-0.08,'144'),COLORYELLOW;
DRAWTEXT(BARSLAST(T)=1,MACD+0.2,'1'),COLORGREEN;
{DRAWTEXT(BARSLAST(T)=2,MACD+0.1,'2'),COLORGREEN;}
DRAWTEXT(BARSLAST(T)=3,MACD+0.09,'3'),COLORGREEN;
DRAWTEXT(BARSLAST(T)=5,MACD+0.09,'5'),COLORGREEN;
DRAWTEXT(BARSLAST(T)=8,MACD+0.08,'8'),COLORGREEN;
DRAWTEXT(BARSLAST(T)=13,MACD+0.08,'13'),COLORGREEN;
DRAWTEXT(BARSLAST(T)=18,MACD+0.08,'18'),COLORGREEN;
DRAWTEXT(BARSLAST(T)=21,MACD+0.08,'21'),COLORGREEN;
DRAWTEXT(BARSLAST(T)=29,MACD+0.08,'29'),COLORGREEN;
DRAWTEXT(BARSLAST(T)=34,MACD+0.08,'34'),COLORGREEN;
DRAWTEXT(BARSLAST(T)=55,MACD+0.08,'55'),COLORGREEN;
DRAWTEXT(BARSLAST(T)=89,MACD+0.08,'89'),COLORGREEN;
DRAWTEXT(BARSLAST(T)=144,MACD+0.08,'144'),COLORGREEN;
{MACD面积}
P:=12;S:=26;M:=9;
DIFF:EMA(C,P) - EMA(C,S);
MACD值:2*(DIFF-DEA),COLORSTICK,COLORRED;
BV:=SUM(MACD值,0);
BA:=IF(MAX(BV,REF(BV,2))<REF(BV,1) OR MIN(BV,REF(BV,2))>REF(BV,1),1,0);
BC:=BARSLAST(BA)+1;
SMACD:=BV-REF(BV,BC);
VAR3:=IF(MACD值>0,HHV(ABS(MACD值),BC),LLV(MACD值,BC));
VAR4:=(MACD值)/20;{图形比例缩小1/20,可修改}
面积:SMACD,NODRAW;
DRAWNUMBER(REF(VAR4,1)>0 AND VAR4<=0 ,REF(VAR3,1),REF(面积,1)),COLORMAGENTA;
DRAWNUMBER(REF(VAR4,1)<0 AND VAR4>=0 ,REF(VAR3,1),REF(ABS(面积),1)),COLORMAGENTA;
DRAWNUMBER(ISLASTBAR AND VAR4<0,REF(VAR3,1),ABS(面积)),COLORMAGENTA;
DRAWNUMBER(ISLASTBAR AND VAR4>0,REF(VAR3,1),面积),COLORMAGENTA;