/*[[ Name := MACD Author := Copyright © 2003, MetaQuotes Software Corp. Link := http://www.metaquotes.ru/ Separate Window := Yes First Color := Black First Draw Type := Histogram Use Second Data := Yes Second Color := Black Second Draw Type := Line ]]*/ Inputs : Average(10); Variables : shift(0), cnt(0), sum(0), loopbegin1(0), first(True),cci(0); SetLoopCount(0); // initial checkings If first Then Begin loopbegin1 = Bars;//-Average-1; If loopbegin1 < 0 Then Exit; // not enough bars for counting first = False; // this block is to be evaluated once only End; // convergence-divergence loopbegin1 = loopbegin1+1; // current bar is to be recounted too For shift = loopbegin1 Downto 0 Begin cci=iCCIEx(14,PRICE_TYPICAL,shift); if cci == 0 then cci=0.000001; SetIndexValue(shift,cci); SetIndexValue2(shift,cci); loopbegin1 = loopbegin1-1; // prevent to previous bars recounting End;