LMD:=5;BARS:=BARSCOUNT(C);
ZZ:=SUM(AMOUNT,BARS)/SUM(V*100,BARS);
JX:=C;
A1:=EMA(C,6);
A2:=EMA(C,20);
A3:=EMA(C,60);
JD1:=ATAN((A1/REF(A1,1)-1)*100)*57.3;
JD2:=ATAN((A2/REF(A2,1)-1)*100)*57.3;
JD3:=ATAN((A3/REF(A3,1)-1)*100)*57.3;
PC:=(A1/JX-1)*100;
ZF:=(C/DYNAINFO(3)-1)*100;
JDC:=JD3-JD2;
FL:=COUNT(V/REF(MA(V,10),5) > 2,10) >=3 OR COUNT(V/REF(MA(V,10),5) > 5,10) >=1;
BP:=FL AND (ZF < -1*LMD OR PC < -1*LMD) AND COUNT(JD3 < -1,20) > 5 AND JD3 < 0 AND LONGCROSS(JD1,0,6);
SP:=FL AND ZF > LMD AND PC > LMD AND COUNT(JD2-JD3 > 1,20) > 5 AND JD3 > 0 AND LONGCROSS(0,JD1,6);
BPS:=IF(BARSSINCE(BP)=0 OR (BP AND (C/REF(C,BARSSINCE(BP))-1)*100 < -1*LMD),1,0);
SPS:=IF(BARSSINCE(SP)=0 OR (SP AND (C/REF(C,BARSSINCE(SP))-1)*100 > LMD),1,0);
STICKLINE(BPS,0,0.5,10,0),COLORRED;
STICKLINE(SPS,0.5,1,10,0),COLORGREEN;