ABC:=MAX(O,C);
CBA:=MIN(O,C);
DEF:=REF(HHV(H,2),1);
FED:=REF(LLV(L,2),1);
X:=IF(ABC>DEF,1,IF(CBA<FED,-1,0));
XX:=BARSLAST(X=0);
TH:=REF(REF(H,BARSLAST(X=1)),XX);
TL:=REF(REF(L,BARSLAST(X=-1)),XX);
TA:=IF(X=1,IF(ABC>TH,1,0),IF(X=-1,IF(CBA<TL,-1,0),0));
X3:=BARSLAST(TA=-1);
X4:=BARSLAST(TA=1);
RE:=REF(COUNT(CROSS(TA,-0.5),X4),X3);
RF:=COUNT(CROSS(TA,0.5),X3);
TB:=IF(TA=1,IF(RF=1,IF(RE>0,1,0),0),0);
NOTEXT1:=VALUEWHEN(TB,REF(REF(H,X4),X3)),COLORGREEN,LINETHICK2;
乖离:=100*ABS(C-NOTEXT1)/NOTEXT1<10;
DIF:=EMA(CLOSE,18)-EMA(CLOSE,40);
DEA:=EMA(DIF,3);
MACD:=(DIF-DEA)*2;
MAD:=MACD;
MBW:=MACD;
MCM:=MACD;
MS:=MACD;
NOTEXTMACD1:EMA((MAD+MBW*7+MCM*31+MS*94)/133,5) LINETHICK2 COLORYELLOW NODRAW;
STICKLINE(NOTEXTMACD1>0,NOTEXTMACD1,0,3,1),COLORRED;
STICKLINE(NOTEXTMACD1<0,NOTEXTMACD1,0,3,1),COLORCYAN;
NOTEXTMACD120:REF(NOTEXTMACD1/2,BARSLAST(NOTEXTMACD1=HHV(NOTEXTMACD1,12))),COLORRED,LINETHICK1;
NOTEXTMACD250:REF(NOTEXTMACD1/2,BARSLAST(NOTEXTMACD1=HHV(NOTEXTMACD1,250))),COLORWHITE,LINETHICK1;
XG:=NOT(REF(NOTEXTMACD120,1)=NOTEXTMACD120);
STICKLINE(XG,0,NOTEXTMACD1,2,0),COLORYELLOW;
STICKLINE(NOTEXTMACD1>=NOTEXTMACD250,NOTEXTMACD250,NOTEXTMACD1,2,0),COLORMAGENTA;
大行情:=NOT(REF(NOTEXTMACD120,1)=REF(NOTEXTMACD250,1)) AND NOTEXTMACD120=NOTEXTMACD250 AND C>NOTEXT1 AND 乖离;
NOTEXT前高:IF(HHVBARS(MACD ,90) ,REF(MACD ,HHVBARS(MACD,90) ),MACD )COLORYELLOW,LINETHICK2;
NOTEXX3:IF(NOTEXT前高>REF(NOTEXT前高,1),NOTEXT前高,DRAWNULL),COLORMAGENTA,LINETHICK4;
NOTEXX4:IF(NOTEXT前高<REF(NOTEXT前高,1),NOTEXT前高,DRAWNULL),COLORGREEN,LINETHICK4;
DRAWICON(XG AND NOTEXTMACD1>=NOTEXTMACD250,NOTEXX3,5);
DRAWTEXT(大行情 AND NOTEXT前高>NOTEXTMACD250,-0.01,'牛启'),COLORYELLOW;