/*[[ Name := XO_ATR Author := Copyright © 2004, MechanicalTrade Co. Link := Aborigen Separate Window := Yes First Color := Blue First Draw Type := Histogram First Symbol := 217 Use Second Data := Yes Second Color := Red Second Draw Type := Histogram Second Symbol := 218 ]]*/ Variable : shift(0),First(True),Trend(0),Up(0),Down(0),CurAtr(0); Input: Box(1), Revers(3), ATR(10); If First then Begin if C[Bars-10]>O[Bars-10] then trend=1 else trend=0; Up=C[Bars-10];Down=C[Bars-10]; First=False; end; SetLoopCount(0); // loop from first bar to current bar (with shift=0) For shift=Bars-10 Downto 0 Begin CurAtr=iAtr(ATR,shift); If trend=1 then Begin IF H[Shift]Up+(CurAtr*Box) and Up>0 then Up=Up+((H[Shift]-Up)/Ceil(CurAtr*Box)); end; If trend=0 then Begin IF L[Shift]>Down-(CurAtr*Box) and H[Shift]>Down+(CurAtr*Box*Revers) then Begin trend=1; Up=Down+((H[Shift]-Down)/Ceil(CurAtr*Box)); Down=0; end; IF L[Shift]0 then Down=Down-((Down-L[Shift])/Ceil(CurAtr*Box)); end; SetIndexValue(shift, Up); SetIndexValue2(shift, Down); End;