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

Notification

Icon
Error

Options
Go to last post Go to first unread
Lelouch  
#1 Posted : Wednesday, October 27, 2010 9:47:28 PM(UTC)
Lelouch

Rank: Newbie

Groups: Registered, Registered Users
Joined: 9/6/2010(UTC)
Posts: 6

Hi, I need help for this code: If(H>Ref(HHV(H, 3*250),-1),3,0) It is simply plotting a line at '3' when the current high is higher than the last 3 years bar. The problem with this is that if the stock data is less than 3 years, or new warrants, then metastock will popup an error. Is there any function similar like 'barsince' that I can use for doing the if statement to check the number of bars loaded in that chart?
vienna  
#2 Posted : Thursday, October 28, 2010 1:20:49 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

I think this should work:

Code:

n:=If(LastValue(Cum(1))<3*250,5,3*250);

If(Cum(1)<3*250,0,
If(H>Ref(HHV(H, LastValue(n)),-1),3,0));

Lelouch  
#3 Posted : Thursday, October 28, 2010 10:50:00 PM(UTC)
Lelouch

Rank: Newbie

Groups: Registered, Registered Users
Joined: 9/6/2010(UTC)
Posts: 6

Thanks, it worked. for this if statement: n:=If(LastValue(Cum(1))<3*250,5,3*250); if the value less than 3*250, then 5 else 3*250. is there any reason for using number 5?
vienna  
#4 Posted : Friday, October 29, 2010 12:49:43 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

Not really you can also use any number of days even if it is small. However in the final result it would not be used because of the second if statement.
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.