/*[[ Name := GannTrend Author := Copyright © 2004, MechanicalTrade Co. Link := http://www.mechanicaltrade.ru Separate Window := No First Color := Blue First Draw Type := Symbol First Symbol := 236 Use Second Data := Yes Second Color := Red Second Draw Type := Symbol Second Symbol := 238 ]]*/ Input: Periods(6); Variable : shift(0),Swing(1),stoh(0),SwingHigh(0),SwingLow(0); Var: LastHigh(0),LastLow(0),Trend(0),prevbars(0),loopbegin1(0),ttime(0),First(True); if ttime=time and loopbegin1=-1 then exit; ttime=time; if bars<100 then exit; 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=0.5 else trend=-0.5; 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); Stoh=iWPR(Periods,Shift); If Swing=-1 and Stoh>-30 then Begin Swing=1; LastLow=SwingLow; SwingHigh=H[Shift]; //If Trend=0.5 then SetIndexValue(shift, H[Shift]); end; If Swing=1 and Stoh<-70 then Begin Swing=-1; LastHigh=SwingHigh; SwingLow=L[Shift]; //If Trend=-0.5 then SetIndexValue2(shift, L[Shift]); end; If Swing=1 and H[Shift]>SwingHigh then SwingHigh=H[Shift]; If Swing=-1 and L[Shift]LastHigh then Begin Trend= 0.5; SetIndexValue(shift, L[Shift]-20*Point); end; If Trend= 0.5 and SwingLow