MTR:=EMA(MAX(MAX(HIGH-LOW,Abs(HIGH-REF(CLOSE,1))),ABS(REF(CLOSE,1)-LOW)),13);
HD:=HIGH-REF(HIGH,1);
LD:=REF(LOW,1)-LOW;
DMP:=EXPMEMA(IF(HD>0&&HD>LD,HD,0),13);
DMM:=EXPMEMA(IF(LD>0&&LD>HD,LD,0),13);
pdi:=DMP*100/MTR;
mdi:=DMM*100/MTR;
ADX:=EXPMEMA((PDI-MDI)/(MDI+PDI)*100,3),COLORMAGENTA,LINETHICK2;
ADXR:=EXPMEMA(ADX,5),COLORGREEN,LINETHICK2;
D:=PDI-22;
K:=MDI-22;
上涨:=ADX>ADXR;
下跌:=ADXR>ADX;
牛盘整:=PDI>dmi AND ADX>16 AND ADX<30;
熊盘整:=PDI<DMI AND ADX>16 AND ADX<30;
熊市:=PDI<DMI AND ADX<ADXR;
低1:=REF(LLV(L-L*0.04,133),3);
低2:=REF(LLV(L-L*0.08,133),3);
低3:=REF(LLV(L-L*0.06,133),3);
STICKLINE(上涨=1,REFDATE(低1,DATE),REFDATE(低1,DATE)*0.985,4,0)COLORLIRED;
STICKLINE(下跌=1,REFDATE(低1,DATE),REFDATE(低1,DATE)*0.985,4,0)COLOR339933;
STICKLINE(熊市,REFDATE(低3,DATE),REFDATE(低3,DATE)*0.983,4,0)COLORGRAY;
STICKLINE(牛盘整,REFDATE(低3,DATE),REFDATE(低3,DATE)*0.983,4,0)COLORMAGENTA;
STICKLINE(熊盘整,REFDATE(低3,DATE),REFDATE(低3,DATE)*0.983,4,0)COLOR99FF33;
DRAWICON(crOSS(ADX,ADXR),REFDATE(低1,DATE)*0.97,1);
DRAWICON(CROSS(ADXR,ADX),REFDATE(低1,DATE)*0.97,2);
STICKLINE(D>K,REFDATE(低2,DATE),REFDATE(低2,DATE)*0.97,4,0)COLORRED;
STICKLINE(K>D,REFDATE(低2,DATE),REFDATE(低2,DATE)*0.97,4,0)COLORGREEN;