/*[[ Name := t3_Aroon_Osc_Ped Author := Copyright © 2004, David W Honeywell Link := DavidHon@msn.com Notes := You must have the t3_Aroon_1_Not_Smoothed and the t3_Aroon_2_Smoothed also for this to work. Separate Window := yes First Color := Cyan First Draw Type := Line First Symbol := 217 Use Second Data := No Second Color := Red Second Draw Type := Line Second Symbol := 218 ]]*/ Input : t3_period(5), Aroon1(12),Aroon2(12),b(0.618); Variable : t3(0),shift(0),med(0); Variable : b2(0),b3(0); Variable : e1(0),e2(0),e3(0),e4(0),e5(0),e6(0); Variable : n(0),w1(0),w2(0); Variable : t32(0),A1(0),A2(0),t33(0); Variable : c1(0),c2(0),c3(0),c4(0); Variable : e12(0),e22(0),e32(0),e42(0),e52(0),e62(0); Variable : e13(0),e23(0),e33(0),e43(0),e53(0),e63(0); var : HighestBar(0),LowestBar(0); var : aroonUp(0),aroonDn(0), calculate_period(0); Variable : prevbars(0), first(true), loopbegin(0), chk(0); If Bars < prevbars Or Bars-prevbars>1 Then first = True; if chk <> t3_period+Aroon1+Aroon2+b then first = true; chk = t3_period+Aroon1+Aroon2+b; prevbars = Bars; If first Then Begin // loopbegin prevent couning of counted bars exclude current loopbegin = Bars-1-Aroon1; If loopbegin < 0 Then Exit; // not enough bars for counting first = False; End; b2=b*b; b3=b2*b; c1=-b3; c2=(3*(b2+b3)); c3=-3*(2*b2+b+b3); c4=(1+3*b+b3+3*b2); n=t3_period; if n<1 then n=1; n = 1 + 0.5*(n-1); w1 = 2 / (n + 1); w2 = 1 - w1; SetLoopCount(0); //loopbegin = loopbegin+1; // current bar is to be recounted too For shift = loopbegin Downto 0 Begin SetIndexValue(shift, 0); calculate_period = Aroon1; HighestBar = Highest(MODE_HIGH,shift+(calculate_period-1),calculate_period); aroonUp = 100 - ((HighestBar - shift) / calculate_period) * 100; if(aroonUp == 0) then { aroonUp = 0.0000001; } calculate_period = Aroon2; LowestBar = Lowest(MODE_LOW,shift+(calculate_period-1),calculate_period); aroonDn = 100 - ((LowestBar - shift) / calculate_period) * 100; if(aroonDn == 0) then { aroonDn = 0.0000001; } A1 = aroonUp; e1 = w1*A1 + w2*e1; e2 = w1*e1 + w2*e2; e3 = w1*e2 + w2*e3; e4 = w1*e3 + w2*e4; e5 = w1*e4 + w2*e5; e6 = w1*e5 + w2*e6; t3 = c1*e6 + c2*e5 + c3*e4 + c4*e3; A2 = aroonDn; e12 = w1*A2 + w2*e12; e22 = w1*e12 + w2*e22; e32 = w1*e22 + w2*e32; e42 = w1*e32 + w2*e42; e52 = w1*e42 + w2*e52; e62 = w1*e52 + w2*e62; t32 = c1*e62 + c2*e52 + c3*e42 + c4*e32; med=t3-t32; e13 = w1*med + w2*e13; e23 = w1*e13 + w2*e23; e33 = w1*e23 + w2*e33; e43 = w1*e33 + w2*e43; e53 = w1*e43 + w2*e53; e63 = w1*e53 + w2*e63; t33 = c1*e63 + c2*e53 + c3*e43 + c4*e33; SetIndexValue(shift, t33); // loopbegin = loopbegin-1; // prevent to previous bars recounting End;