/*[[ Name := Forecast Oscillator Author := Hapsa Notes := Codes from LRI by Nick Bilak, beluck[at]ukr.net Link :=http://finance.groups.yahoo.com/group/MetaTrader_Experts_and_Indicators Separate Window := Yes First Color := LightSkyBlue First Draw Type := Line First Symbol := 217 Use Second Data := Yes Second Color := MediumSpringGreen Second Draw Type := Line Second Symbol := 218 ]]*/ Inputs : Rperiod(15), t3_period(10), b(0.7); Variables : shift(0), cnt(0), loopbegin(0), first(True), prevbars(0); Variables : sum(0), length(0), i(0), mt(0), WT(0), vWT2(0),value(0), forecastosc(0), MA(0); Variables : t3(0); Variables : e1(0),e2(0),e3(0),e4(0),e5(0),e6(0),c1(0),c2(0),c3(0),c4(0); Variables : n(0),w1(0),w2(0), b2(0),b3(0); Variables : t3_fosc(0); 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); // initial checkings If RPeriod < 1 Then Exit; length=RPeriod; loopbegin = 206-length-1; For shift = loopbegin Downto 0 Begin sum=0; For i = length downTo 1 Begin sum = sum + (i-(length+1)/3)*Close[length-i+shift]; End; WT=sum*6/(length*(length+1)); forecastosc=(C[shift]-WT)/WT*100; SetIndexValue2(shift, 0); e1 = w1*forecastosc + 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_fosc = c1*e6 + c2*e5 + c3*e4 + c4*e3; SetIndexValue(shift,forecastosc); SetIndexValue2(shift,t3_fosc); End;