L3:=IF(MD4 MD3 OR (MD4=MD3 AND L2=0),1,0);
L4:=IF(MD5 MD4 OR (MD5=MD4 AND L3=0),1,0);
L5:=IF(MD6 MD5 OR (MD6=MD5 AND L4=0),1,0);
L6:=IF(C MD6 OR (C=MD6 AND L5=0),1,0);
LL1:=L1+L2*2+L3*4;
LL2:=L4+L5*2+L6*4;
GG:=IF(LL2=7 OR LL2=3,H,0.5*L);
GD:=IF(LL2=0 OR LL2=4,L,1.5*H);
均线顶0:=LL2=7 OR (LL2=3 AND (REF(LL2,1)=7 OR REF(LL2,1)=3) AND (H REF(H,1) )) ;
均线底0:=LL2=0 OR (LL2=4 AND (REF(LL2,1)=0 OR REF(LL2,1)=4) AND (L REF(L,1))) ;
GG2:=IF(均线顶0,H,0.9*H);
GD2:=IF(均线底0,L,1.1*L);
均线顶A:=FILTERX(均线顶0 AND GG2=HHV(GG2,BARSLAST(均线底0)),BARSLAST(均线底0));
均线底A:=FILTERX(均线底0 AND GD2=LLV(GD2,BARSLAST(均线顶0)),BARSLAST(均线顶0));
均线顶:=FILTERX(均线顶A AND GG2=HHV(GG2,BARSLAST(均线底A)),BARSLAST(均线底A));
均线底:=FILTERX(均线底A AND GD2=LLV(GD2,BARSLAST(均线顶A)),BARSLAST(均线顶A));
顶高:=REF(H,BARSLAST(均线顶));
底底:=REF(L,BARSLAST(均线底));
{
修正顶A:=均线顶 OR ((LL2=1 OR LL2=3 OR LL2=5) AND BARSLAST(均线顶) BARSLAST(均线底) AND H=HHV(H,BARSLAST(均线顶)+1));
修正底A:= 均线底 OR ((LL2=2 OR LL2=4 OR LL2=6) AND BARSLAST(均线底) BARSLAST(均线顶) AND L=LLV(L,BARSLAST(均线底)+1));
GG3:=IF(修正顶A,H,0.9*H);
GD3:=IF(修正底A,L,1.1*L);
修正顶:=FILTERX(修正顶A AND GG3=HHV(GG3,BARSLAST(修正底A)),BARSLAST(修正底A));
修正底:=FILTERX(修正底A AND GD2=LLV(GD3,BARSLAST(修正顶A)),BARSLAST(修正顶A));}
修正顶:=均线顶;
修正底:=均线底;
X1:=IF(修正底,BARSLAST(修正顶),IF(修正顶,BARSLAST(修正底),0));
EREA:=IF(修正底,SQRT(X1)*(REF(H,X1)-L),IF(修正顶,(H-REF(L,X1))*SQRT(X1),0));
Y1:=REF(X1,X1)+X1;
EREA2:=REF(EREA,Y1);
V1:=IF(修正底 OR 修正顶, SUM(V,X1)/10000,0);
DRAWNUMBER(修正底 ,L*0.97,V1),COLORYELLOW;
DRAWNUMBER(修正底 ,L*0.98,EREA),COLORRED;
DRAWTEXT(修正底 ,L*0.99,CON2STR(L,2)),COLORGREEN;
DRAWNUMBER( 修正顶,H*1.03,V1),COLORYELLOW;
DRAWNUMBER( 修正顶,H*1.02,EREA),COLORRED;
DRAWTEXT( 修正顶,H*1.01,CON2STR(H,2)),COLORLIRED;
DRAWLINE(修正底,LOW,修正顶 AND EREA EREA2, HIGH,0),COLORMAGENTA,LINETHICK3;
DRAWLINE(修正底,LOW,修正顶 AND EREA = EREA2 , HIGH,0),COLORMAGENTA,LINETHICK1;
DRAWLINE(修正顶,HIGH,修正底 AND EREA EREA2 , LOW,0),COLORGREEN,LINETHICK3;
DRAWLINE(修正顶,HIGH,修正底 AND EREA = EREA2 , LOW,0),COLORGREEN,LINETHICK1;
{
DRAWICON(均线顶,H,5);
DRAWICON(均线底,L,6);
};