DIF:EMA(CLOSE,12)-EMA(CLOSE,26),COLOR0000FF;
DEA:EMA(DIF,9),COLORBLUE;
{布林中轨(20日均线)}
MA20:=MA(CLOSE,20);
MACD2:=2*(C-MA20);
{布林上下轨}
UPPER:=MA20+2*STD(CLOSE,20);
LOWER:=MA20-2*STD(CLOSE,20);
UP:2*(UPPER-MA20),DOTLINE;
LO:2*(LOWER-MA20),DOTLINE;
{收盘价与布林线关系(大于或小于布林中轨)}
STICKLINE(MACD2>0,0,MACD2,1.5,1),COLORMAGENTA;
STICKLINE(MACD2<0,0,MACD2,1.5,1),COLORCYAN;
{布林标注}
DRAWTEXT(CROSS(C,LOWER),LO,'↑安全');
DRAWTEXT(CROSS(UPPER,C),UP,'★风险'),COLORGREEN;
{5日均线}
MA5:=MA(CLOSE,5);
MACD1:2*(C-MA5),STICK;
{收盘价与5日均线关系(大于或小于5日均线)}
STICKLINE(MACD1>0,0,MACD1,0.5,0),COLOR0000DD;
STICKLINE(MACD1<0,0,MACD1,0.5,0),COLOR00BB00;
VAR1:=MACD2>REF(MACD2,1) AND REF(MACD2,1)<REF(MACD2,2) AND REF(MACD2,2)<REF(MACD2,3);{收盘价连续下跌两天反弹}
VAR2:=REF(MACD1,1)<0 AND MACD1>0;{收盘价上穿5日均线,也可以写成CROSS(C,MACD1);}
VAR3:=MA20>REF(MA20,1){20日均线向上};
DRAWICON(VAR1 AND VAR2 AND VAR3,0,9);{回踩买(钱袋标志)};
DIF*10,COLOR0000FF;
DEA*10,COLORBLUE;