/*[[ 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 := 133 Use Second Data := No ]]*/ Inputs : CCIP(14), limit(50), delta(15), 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),pmn3(0),pmx1(0),pmx2(0),pmx3(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; pmx3=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 pmx2!=0 and pmx3==0 then { pmx3=tt[sh+1]; } if pmx1!=0 and pmx2==0 then { pmx2=tt[sh+1]; } if pmx1==0 then { pmx1=tt[sh+1]; } } } } pmn1=0; pmn2=0; pmn3=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 pmn2!=0 and pmn3==0 then { pmn3=tt[sh+1]; } if pmn1!=0 and pmn2==0 then { pmn2=tt[sh+1]; } if pmn1==0 then { pmn1=tt[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));*/ // Ghost в нисходящем тренде if cciD>=6 and pmn3!=0 and pmn1>pmn2 and pmn3>pmn2+delta and pmn1<0 //and pmn3<0 and tt[0]-delta>pmn1 and tt[0]>tt[1] and not(tt[1]-delta>pmn1) // and pmx1<=0 and pmx1>=-limit // and pmx2<=limit and pmx2>=-limit then { val=L[shift]-7*Point; //val=1; } // Ghost в восходящем тренде if cciU >=6 and pmx3!=0 and pmx10 //and pmx3>0 and tt[0]+delta=0 // and pmn2<=limit and pmn2>=-limit then { val=H[shift]+7*Point; //val=-1; } SetIndexValue(shift,val); loopbegin = loopbegin-1; End;