N:=5;
N1:=10;
N2:=20;
DIR:=ABS(CLOSE-REF(CLOSE,n));
VIR:=SUM(ABS(CLOSE-REF(CLOSE,1)),n);
ER:=DIR/VIR;
CS:=ER*(2/3-2/31)+2/31;
CQ:=CS*CS;
AMA:DMA(CLOSE,CQ), COLORWHITE,linethick1;
DIR1:=ABS(CLOSE-REF(CLOSE,n1));
VIR1:=SUM(ABS(CLOSE-REF(CLOSE,1)),n1);
ER1:=DIR1/VIR1;
CS1:=ER1*(2/3-2/31)+2/31;
CQ1:=CS1*CS1;
AMA10:DMA(CLOSE,CQ1),COLORYELLOW,linethick2;
DIR2:=ABS(CLOSE-REF(CLOSE,n2));
VIR2:=SUM(ABS(CLOSE-REF(CLOSE,1)),n2);
ER2:=DIR2/VIR2;
CS2:=ER2*(2/3-2/31)+2/31;
CQ2:=CS2*CS2;
AMA20:DMA(CLOSE,CQ2),COLORGREEN,linethick3;
PARTLINE(AMA20,AMA20>REF(AMA20,1),rgb(255,0,0)),linethick3;
DRAWTEXT(C*BACKSET(BARSTATUS=2,6)>0 AND C*BACKSET(BARSTATUS=2 ,5)=0,L*0.999,'5日'),COLORYellow,LINETHICK2;
DRAWTEXT(C*BACKSET(BARSTATUS=2,11)>0 AND C*BACKSET(BARSTATUS=2 ,10)=0,L*0.998,'10日'),COLORYellow,LINETHICK2;
DRAWTEXT(C*BACKSET(BARSTATUS=2,21)>0 AND C*BACKSET(BARSTATUS=2 ,20)=0,L*0.998,'20日'),COLORYellow,LINETHICK2;
DRAWTEXT(C*BACKSET(BARSTATUS=2,31)>0 AND C*BACKSET(BARSTATUS=2 ,30)=0,L*0.998,'30日'),COLORYellow,LINETHICK2;
DRAWTEXT(C*BACKSET(BARSTATUS=2,61)>0 AND C*BACKSET(BARSTATUS=2 ,60)=0,L*0.998,'60日'),COLORYellow,LINETHICK2;
DRAWTEXT(C*BACKSET(BARSTATUS=2,121)>0 AND C*BACKSET(BARSTATUS=2 ,120)=0,L*0.998,'120日'),COLORYellow,LINETHICK2;
DRAWTEXT(C*BACKSET(BARSTATUS=2,241)>0 AND C*BACKSET(BARSTATUS=2 ,240)=0,L*0.998,'240日'),COLORYellow,LINETHICK2;