/*[[ 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 := 132 Use Second Data := No ]]*/ Inputs : CCIP(14), limit(200), delta(10), 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),kmn(0),kmx(0),line(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; pmn1=0; // Определение точек. if cciD>=6 then { For sh = 13 downto 1 { if tt[sh]<=tt[sh+1] and tt[sh+1]>=tt[sh+2] and pmn1!=0 and pmx1==0 then { pmx1=tt[sh+1]; tmx1=sh+1; } if tt[sh]>=tt[sh+1] and tt[sh+1]<=tt[sh+2] and pmn1==0 and tt[sh+1]<=-limit and sh+1>=5 then { pmn1=tt[sh+1]; tmn1=sh+1; } } } pmx2=0; pmn2=0; // Определение точек. if cciU>=6 then { For sh = 13 downto 1 { if tt[sh]>=tt[sh+1] and tt[sh+1]<=tt[sh+2] and pmn2!=0 and pmx2==0 then { pmn2=tt[sh+1]; tmn2=sh+1; } if tt[sh]<=tt[sh+1] and tt[sh+1]>=tt[sh+2] and pmx2==0 and tt[sh+1]>=limit and sh+1>=5 then { pmx2=tt[sh+1]; tmx2=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));*/ // Vegas в нисходящем тренде if pmx1!=0 and cciD>=6 and tt[1]=pmx1 and tt[0]-delta>tt[1] // and tt[0]>tt[1] and not(tt[1]-delta>tt[2]) then { val=L[shift]-6*Point; //val=-1; } // Vegas в восходящем тренде if pmn2!=0 and cciU >=6 and tt[1]>pmn2 and tt[0]<=pmn2 and tt[0]+delta