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

Notification

Icon
Error

Options
Go to last post Go to first unread
oem7110  
#1 Posted : Thursday, December 16, 2010 2:57:25 AM(UTC)
oem7110

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/30/2005(UTC)
Posts: 120

I would like to look for the previous third H, which the second and third H is higher than current H. For example,

(5 Nov) H: 100 (Current bar)

(4 Nov) H: 95, which does not count, because 95 is smaller than 100,

(3 Nov) H:102, which count as a second high, because 102 is higher than 100,

(2 Nov) H:101, which does not count, because 101 is smaller than 102 (Previous High),

(1 Nov) H:105, which count as a third high, because 105 is higher than 102

Does anyone have any suggestions on how to code the formula and display 105 on 5 Nov?

Thanks in advance for any suggestions

johnl  
#2 Posted : Thursday, December 16, 2010 7:04:39 PM(UTC)
johnl

Rank: Advanced Member

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


Try something like:

p1:=However you define a high
ValueWhen(3,p1=1,H);



oem7110  
#3 Posted : Thursday, December 16, 2010 7:11:25 PM(UTC)
oem7110

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/30/2005(UTC)
Posts: 120

johnl wrote:

Try something like: (code from Roy from this forum)

p1:=However you define a high
count:=Cum(1);
reset:=p1;
counter:=count-ValueWhen(1,reset,count);
counter;
Change the 1 for however many back you want to go, in your case, 3.

Could you please explain more from Roy's coding? I get no idea on what it does.

Thank you very much for suggestions

oem7110  
#4 Posted : Friday, December 17, 2010 12:10:00 AM(UTC)
oem7110

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/30/2005(UTC)
Posts: 120

johnl wrote:

Try something like:
p1:=However you define a high
ValueWhen(3,p1=1,H);

To define a high:

From any current bar, I would like to look back the third previous high, only any previous high, which is higher than current bar's high, would be counted, starting from 1 (current bar), 2 (previous high), 3 (previous high).

Do you have any suggestions on how to code it in Metastock? I find difficult on coding it in Metastock language, Please help.

Thank you very much for any suggestion

wabbit  
#5 Posted : Friday, December 17, 2010 2:31:17 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Needs to be done as an external function as the code would require loops.


wabbit [:D]
oem7110  
#6 Posted : Friday, December 17, 2010 5:14:44 AM(UTC)
oem7110

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/30/2005(UTC)
Posts: 120

wabbit wrote:
Needs to be done as an external function as the code would require loops.
wabbit [:D]

Instead of using loops, is there any other approach to solve this issue?

such as counting the number of period, where high is higher than current bar's high.

If(H<Ref(H,-1),1,PREV+1), but this condition is very complicated to me.

Does anyone have any idea on this approach?

Thank everyone very much for any suggestions[:D]

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.