N:=10;
M:=1.5;
TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR:=MA(TR1,N);
MEDIAN:= (HIGH + LOW) / 2;
UP:= MEDIAN+ATR * M;
DN:= MEDIAN-ATR * M;
TR2:=IF(C>REF(UP,1),1,IF(C<REF(DN,1),-1,TR1));
FLAG:=TR2<0 AND REF(TR2,1)>0;
FLAGH:=TR2>0 AND REF(TR2,1)<0;
DN1:=IF(TR2>0 AND DN<REF(DN,1),REF(DN,1),DN);
UP1:=IF(TR2<0 AND UP>REF(UP,1),REF(UP,1),UP);
UP2:=IF(FLAG,MEDIAN + ATR * M,UP1);
DN2:=IF(FLAGH,MEDIAN - ATR * M,DN1);
STICKLINE(C<REF(UP2,1),0,1,5,0),COLOR0000FF;
STICKLINE(C>REF(UP2,1),0,1,5,0),COLOR00FF00;