logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
JakDangerous  
#1 Posted : Monday, March 23, 2009 2:52:06 AM(UTC)
JakDangerous

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 3/23/2009(UTC)
Posts: 1

Hi All,

I am new to the forum and still very new to MetaStock so I was wondering if someone could perhaps shed a little light on a coding problem I am stuck on. Here goes....

I made a simplified Elder Ray indicator which shows postive bull power and negative bear power on the one histogram (and does not plot negative bull power or positive bear power). The code follows:

BullPwr:=If(H-Mov(C,22,E)<0,0,H-Mov(C,22,E));
BearPwr:=If(L-Mov(C,22,E)>0,0,L-Mov(C,22,E));

BullPwr;
BearPwr;

It's obviously nothing flash but is usefull all the same. What I am wanting to do is create an indicator from these values to use as a profit objective. So in plain english I am wanting to code the following:

{For Long Profit Target Value}

"(The Highest High + the Second Highest High + the Third Highest High) from each of the last three rallys away from the EMA where a 'rally away from the EMA' is defined as at least 10 consecutive bars of positive BullPwr values".

Then once the sum of all this is achieved it will simply be a matter of dividing by nine to return an expectable distance from the EMA at which the price is likely to reach on the next rally.

(Obviously the short side will just be a matter of reversing the appropriate code so I won't repeat it all again here)

Being new to the coding language in MetaStock I am having great difficulty in calculating the Second Highest and Third Highest values. HHV() is simple enough but the others?....Also trying to reference a grouping of bars (the 'rallys away from the EMA') from which to draw these highs is proving tricky also.

Anyway, I will stick at it and post what I come up with when it even starts to resemble workable but until then I would greatly appreciate any assistance you could offer.

Cheers,

Jak

johnl  
#2 Posted : Wednesday, March 25, 2009 9:14:06 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

Try starting with something like this:

{------------------------------------}
bl:=If(H-Mov(C,22,E)<0,0,H-Mov(C,22,E));
br:=If(L-Mov(C,22,E)>0,0,L-Mov(C,22,E));
{------------------------------------}
a1:=(bl>0)*
(Ref(bl,-1)>0)*
(Ref(bl,-2)>0)*
(Ref(bl,-3)>0)*
(Ref(bl,-4)>0)*
(Ref(bl,-5)>0)*
(Ref(bl,-6)>0)*
(Ref(bl,-7)>0)*
(Ref(bl,-8)>0)*
(Ref(bl,-9)>0);
a2:=If((a1=0) AND (Ref(a1,-1)=1),1,0);
{----------------------------}
b1:=(ValueWhen(1,a2=1,C)+
ValueWhen(2,a2=1,C)+
ValueWhen(3,a2=1,C))/3;
b1
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.