/*[[ Name := #CER Author := Copyright Mechanicaltrade LTD. Link := http://www.mechanicaltrade.ru/ Separate Window := No First Color := Blue First Draw Type := Line First Symbol := 217 Use Second Data := Yes Second Color := Red Second Draw Type := Line Second Symbol := 171 ]]*/ Variable : shift(0); Var: loopbegin1(0), first(True), prevbars(0), ttime(0); Vars: CentAvg(0), Up(0), Dn(0), CER(0), UpF(0), DnF(0), CERF(0); Vars: MODE("UP"),REZ(0); Input: ATR(50),Coeficient(3); SetLoopCount(0); if ttime=time and loopbegin1=-1 then exit; ttime=time; If Bars < prevbars Or Bars-prevbars>1 Then first = True; prevbars = Bars; If first Then Begin loopbegin1 = Bars-100; If loopbegin1 < 0 Then Exit; // not enough bars for counting first = False; // this block is to be evaluated once only End; loopbegin1 = loopbegin1+1; For shift = loopbegin1 Downto 0 Begin //---------------------------------------------- REZ=Coeficient*iATR(ATR,shift); If MODE="DOWN" and C[shift+1]>GetIndexValue2(shift+1) and GetIndexValue2(shift+1)>0 then MODE="UP"; //повтор необходим! If C[shift+1]GetIndexValue(shift+1)+REZ then Begin SetIndexValue(shift,Low[shift+1]-REZ); SetIndexValue2(shift,-1); end else Begin SetIndexValue(shift,GetIndexValue(shift+1)); SetIndexValue2(shift,-1); end; end; If MODE="DOWN" then Begin If ( High[shift+1]