Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 12/5/2004(UTC) Posts: 2 Location: Warsaw, Poland
|
Hello!
I try to input an interesting formula to Metastock 7.21. I found out there are some tricks required. Have a look at the code and comment if it is equivalent to the EasyStation code below:
{John Ehlers instant trendline}
Pr:=(HIGH+LOW)/2;
alpha:=0.07;
Itrend:=0;
Trigger:=0;
Itrend := If(Cum(1)<7,(pr+2*Ref(pr,-1)+Ref(pr,-2))/4,((alpha-alpha*alpha/4)*Pr+0.5*alpha*alpha*Ref(Pr,-1)-(alpha-0.75*alpha*alpha)*Ref(Pr,-2)+2*(1-alpha)*PREV-(1-alpha)*(1-alpha)*Ref(PREV,-1)));
Trigger := 2*Itrend - Ref(ITrend,-2);
{plotting}
Itrend;
Trigger;
{code ends here}
The most important is the long Itrend line . There is different formula for first 7 bars, and different for subsequent bars. When I used ref(itrend,-1) instead of prev and ref(itrend,-2) instead of (prev,-1), the indicator plotted wrong.
The original code in EasyStation from Ehlers' book there is as follows:
Inputs: Price((H+L)/2),
alpha(.07);
Vars: Smooth(0),
ITrend(0),
Trigger(0);
ITrend = (alpha - alpha*alpha/4)*Price + .5*alpha*alpha*Price[1] - (alpha- .75*alpha*alpha)*Price[2] + 2*(1 - alpha)*ITrend[1] - (1-alpha)*(1 - alpha)*Itrend[2];
If currentbar < 7 then ITrend = (Price + 2*Price[1] + Price[2]) / 4;
Trigger = 2*Itrend - ITrend[2];
Plot1(Itrend, “ITrend”);
Plot2(Trigger, “Trig”);
Please comment, how would you convert this code. I am not sure if I got it right :(
Best regards,
Tom
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 9/8/2004(UTC) Posts: 2,266
Was thanked: 1 time(s) in 1 post(s)
|
Hi Tom,
I'm so sorry, I remember looking at your formula, testing it out to make sure everything was fine. But when I found out it was ok, I completely forgot to reply :oops:
Everything seems good, I only had concerns with the prev function but it is fine.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 12/5/2004(UTC) Posts: 2 Location: Warsaw, Poland
|
Thanks Patrick! Good to know - I found the new function to work better that previous Ehlers formulas.
Best regards, Tom
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.