/*[[ Name := Gann_HiLo Author := Copyright © 2004, MechanicalTrade Co. Link := http://www.mechanicaltrade.ru Separate Window := No First Color := LightGreen First Draw Type := Symbol First Symbol := 159 Use Second Data := Yes Second Color := Chocolate Second Draw Type := Symbol Second Symbol := 159 ]]*/ Input: Periods(2); Variable : shift(0),First(True),Trend(0),Llow(0),Hhig(0),prevbars(0),loopbegin1(0),ttime(0); if ttime=time and loopbegin1=-1 then exit; ttime=time; If Bars < prevbars Or Bars-prevbars>1 Then first = True; prevbars = Bars; If first Then Begin if C[Bars-100]>O[Bars-100] then trend=1 else trend=-1; loopbegin1 = Bars-100; If loopbegin1 < 0 Then Exit; // not enough bars for counting first = False; // this block is to be evaluated once only End; loopbegin1 = loopbegin1+1; For shift = loopbegin1 Downto 0 Begin //---------------------------------------------- SetLoopCount(0); // loop from first bar to current bar (with shift=0) LLow=iMAEx(Periods,MODE_SMA,1,PRICE_LOW, Shift); Hhig=iMAEx(Periods,MODE_SMA,1,PRICE_High,Shift); If C[Shift+1]Hhig and Trend=1 then Trend=-1; If Trend= 1 then SetIndexValue2(Shift,LLow); If Trend=-1 then SetIndexValue(Shift,Hhig); loopbegin1 = loopbegin1-1; End;