Hi all,
I was tring to replicate an indicator explained by John Ehlers in a youtube video.
I attach the formula as image.
When I try to code it on PRT I dont get any line, I presume is because the definition of Ehlers indicator at time t refers to the same indicator at time t-1:
Indicator:
a = (cos(0.707*360/48)+sin(0.707*360/48)-1)/cos(0.707*360/48)
hp = 0
hp = (1+a/2)*(1-a/2)*(close-2*close[1]+close[2])+2*(1-a)*hp[1]-(1-a)*(1-a)*hp[2]
return hp
Can someone help with that?
MAny thanks
Francesco
I guess I sorted this one by writing this
a = (cos(0.707*360/48)+sin(0.707*360/48)-1)/cos(0.707*360/48)
hp1 = (1+a/2)*(1-a/2)*(close[1]-2*close[2]+close[3])
hp2 = (1+a/2)*(1-a/2)*(close[2]-2*close[3]+close[4])
hp = (1+a/2)*(1-a/2)*(close-2*close[1]+close[2])+2*(1-a)*hp1-(1-a)*(1-a)*hp2
return hp
Do you agree?
Many thanks
Francesco
Francesco,
ecco il codice
alpha1 = (cos(.707*360 / 48) + sin (.707*360 / 48) - 1) / cos(.707*360 / 48)
if barindex>1 then
HP = (1-alpha1/2)*(1-alpha1/2)*(Close-2*dClose(1)+dClose(2))+2*(1-alpha1)*HP[1] - (1 - alpha1)*(1 - alpha1)*HP[2]
else
HP = 0
endif
a1 = EXP(-1.414*3.14159 / 10)
b1 = 2*a1*cos(1.414*180 / 10)
c2 = b1
c3 = -a1*a1
c1 = 1 - c2 - c3
if barindex>1 then
Filt = c1*(hp + hp[1]) / 2 + c2*Filt[1] + c3*Filt[2]
else
filt=0
endif
return filt
Scusami Gabri ma continua a venire una linea pari a zero e basta, a te esce qualcosa di diverso?
Grazie
Francesco
problema risolto, grazie!..:)