/*[[ Name := Silver sen Author := Copyright © 2003, VIAC.RU AlexSilver Link := http://viac.ru/ Separate Window := No First Color := Yellow First Draw Type := Symbol First Symbol := 251 Use Second Data := Yes Second Color := Orange Second Draw Type := Symbol Second Symbol := 251 ]]*/ Inputs : CCIP(14), limit(100), delta(10), KBars(500); // limit - границы в которых находится зигзаг // delta - расстояние между "хвостами" и "серединой" Variables : shift(0), cnt(0), sh(0), loopbegin(0), firstTime(True); Variables : val(0),pmn1(0),pmx1(0); Variables : sum(0), length(25), i(0), WT(0); Variables : cciU(0),cciD(0); Array: tt[3](0); SetLoopCount(0); If firstTime Then { if KBars==0 then { loopbegin = Bars-1; } else { loopbegin = KBars-1; } }; For shift = loopbegin Downto 0 Begin /*sum=0; For i = length downTo 1 Begin sum = sum + (i-(length+1)/3)*Close[length-i+shift]; End; WT=sum*6/(length*(length+1)); */ val=0; cciU=0; cciD=0; For sh = 0 to 3 { // Заполнение массива точек. tt[sh]=iCCIEx(CCIP,PRICE_TYPICAL,shift+sh); } pmx1=0; pmn1=0; For sh = 0 to 1 { // Определение точек минимума. if tt[sh]>=tt[sh+1] and tt[sh+1]<=tt[sh+2] then { if pmn1==0 then { pmn1=tt[sh+1]; } } // Определение точек максимума. if tt[sh]<=tt[sh+1] and tt[sh+1]>=tt[sh+2] then { if pmx1==0 then { pmx1=tt[sh+1]; } } } // выход в нисходящем тренде if pmn1!=0 and tt[0]-delta>pmn1 and not(tt[1]-delta>pmn1) then { val=L[shift]-2*Point; //val=-1; } // выход в восходящем тренде if pmx1!=0 and tt[0]+deltalimit or tt[0]<-limit) and val!=0 then SetIndexValue(shift,val); if tt[0]-limit and val!=0 then SetIndexValue2(shift,val) else /* { if C[shift]>WT // and O[shift]WT then { SetIndexValue2(shift,H[shift]+2*Point); //val=1; } }*/ loopbegin = loopbegin-1; End;