UPPER:= MA(C,29) + 2*STD(C,29);
LOWER:= MA(C,29) - 2*STD(C,29);
DIF:EMA(CLOSE,12)-EMA(CLOSE,26),COLORRED,LINETHICK2;
DEA:EMA(DIF,9),COLORWHITE,LINETHICK2;
持仓段:=4,COLORLIRED;
{}
空仓段:=4,COLORLIGREEN;
MACD:(DIF-DEA)*2,COLORSTICK;
STICKLINE(((MACD<REF(MACD,1)) AND (MACD>0)),0,MACD,1,0),COLORLIBLUE,LINETHICK2;
STICKLINE(((MACD>REF(MACD,1)) AND (MACD<0)),0,MACD,1,0),COLORFF00FF,LINETHICK2;
建仓:IF(DIF<0,DIF,0),COLORYELLOW,LINETHICK2;
加仓:IF(DIF<0,0,DIF),COLORRED,LINETHICK2;
白线破仓:IF(DIF<DEA,DIF,DEA),COLORWHITE,LINETHICK2;
趋势强弱:IF(DIF>DEA,DEA,DEA),COLORFF937F,LINETHICK2;
AA:=REF(DIF,3)=HHV(DIF,2*3+1);
BB:=BACKSET(AA,3+1);
CC:=FILTER(BB,3) AND DIF=HHV(DIF,3+1);
A1:=BARSLAST(REF(CC,1));
顶背离:=REF(CLOSE,A1+1)<CLOSE AND REF(DIF,A1+1)>DIF AND CC;
DRAWLINE(CC,DIF,FILTER(顶背离>0,5),DIF,0),COLORRED,LINETHICK2;
AA2:=REF(DIF,3)=LLV(DIF,2*3+1);
BB2:=BACKSET(AA2,3+1);
CC2:=FILTER(BB2,3) AND DIF=LLV(DIF,3+1);
AA2A:=BARSLAST(REF(CC2,1));
底背离:=REF(C,AA2A+1)>CLOSE AND REF(DIF,AA2A+1)<DIF AND CC2;
DRAWLINE(CC2,DIF,FILTER(底背离>0,5),DIF,0),COLORRED,LINETHICK2;
DRAWLINE(CC2,DIF,FILTER(底背离>0,5),DIF,0),COLORRED,LINETHICK2;