/*[[ Name := Silver sen Author := Copyright © 2003, VIAC.RU AlexSilver Link := http://viac.ru/ Separate Window := No First Color := SlateBlue First Draw Type := Symbol First Symbol := 134 Use Second Data := No ]]*/ Inputs : CCIP(14), limit(70), delta(20), KBars(500);//, yyyy(0), mm(0), dd(0), hh(0), mn(0) // limit - границы в которых находится зигзаг // delta - расстояние между "хвостами" и "серединой" Variables : shift(0), cnt(0), sh(0), loopbegin(0), firstTime(True); Variables : val(0),cciU(0),cciD(0),pmn1(0),pmn2(0),pmx1(0),pmx2(0); Variables : tmn1(0),tmn2(0),tmx1(0),tmx2(0); Array: tt[20](0); SetLoopCount(0); //var1 = StrToTime(NumberToStr(yyyy)+"."+NumberToStr(mm+"."+NumberToStr(dd)+" "+NumberToStr(hh)+":"+NumberToStr(mn)); // current time // moving average If firstTime Then { if KBars==0 then { loopbegin = Bars-1; } else { loopbegin = KBars-1; } }; For shift = loopbegin Downto 0 Begin val=0; cciU=0; cciD=0; For sh = 0 to 19 { // Заполнение массива точек. tt[sh]=iCCIEx(CCIP,PRICE_TYPICAL,shift+sh); // Определение наличия тренда. if sh<=8 then { if tt[sh]>=0 then { cciU++; } else { cciD++; } } } pmx1=0; pmx2=0; // Определение точек максимума. if cciD>=6 then { For sh = 0 to 17 { if tt[sh]<=tt[sh+1] and tt[sh+1]>=tt[sh+2] then { if pmx1!=0 and tmx1<3 and pmx2==0 then { pmx2=tt[sh+1]; tmx2=sh+1; } if pmx1==0 then { pmx1=tt[sh+1]; tmx1=sh+1; } } } } pmn1=0; pmn2=0; // Определение точек минимума. if cciU>=6 then { For sh = 0 to 17 { if tt[sh]>=tt[sh+1] and tt[sh+1]<=tt[sh+2] then { if pmn1!=0 and tmn1<3 and pmn2==0 then { pmn2=tt[sh+1]; tmn2=sh+1; } if pmn1==0 then { pmn1=tt[sh+1]; tmn1=sh+1; } } } } /*Comment("Kmn ", NumberToStr(kmn,5) ,"\n","Kmx ", NumberToStr(kmx,5) ,"\n","pmn1 ", NumberToStr(pmn1,5) ,"\n","pmn2 ", NumberToStr(pmn2,5) ,"\n","pmx1 ", NumberToStr(pmx1,5) ,"\n","pmx2 ", NumberToStr(pmx2,5));*/ // Rev div в нисходящем тренде if pmx2!=0 and pmx1>pmx2 and cciD>=6 and tt[0]+delta=-limit and tmx2-tmx1>=3 // and pmx2<=limit and pmx2>=-limit then { val=H[shift]+8*Point; //val=-1; } // Rev div в восходящем тренде if cciU >=6 and pmn2!=0 and pmn1pmn1 and tt[0]>tt[1] and not(tt[1]-delta>pmn1) and pmn1<=limit and pmn1>=0 and tmn2-tmn1>=3 // and pmn2<=limit and pmn2>=-limit then { val=L[shift]-8*Point; //val=1; } SetIndexValue(shift,val); loopbegin = loopbegin-1; End;