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

Notification

Icon
Error

Options
Go to last post Go to first unread
v.trader  
#1 Posted : Sunday, November 22, 2009 2:10:08 PM(UTC)
v.trader

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/26/2009(UTC)
Posts: 76
Location: Toronto, Canada

Hi everyone, I'am relatively new to Metastock's programming language and I'm kind of confused how the PREV function is used. Can someone explain to me in simple language that? Also, for instance explain how the PREV function works in this example: If(C>Ref(Max(H,Ref(H,-1)),-1),Min(L,Ref(L,-1)),If(C
mstt  
#2 Posted : Sunday, November 22, 2009 3:13:31 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

Hi VT

PREV is simply the previous bars result of this current variable. The result calculated on the previous bar is used as an input for calculating the current bar's value. The Ref() function can only work with a variable or data array that has already been defined but PREV does not require the variable that it's used in to have been defined at some earlier point in the formula. PREV can be seeded with a starting value or it will otherwise assume zero as the starting value (i.e when processing the first data bar there cannot be an actual PREVious value and zero will be assumed in that case). A couple of weeks ago I gave an example of how a variable can be seeded on bar one thus providing a value other than zero for PREV when the next bar's result is calculated - see http://forum.equis.com/forums/thread/31138.aspx.

PREV comes into it's own for decision-making such as when a trade exit is dependant on the trade entry price. Because of it's performance issues the general rule is to never use PREV unless it's absolutely necessary.

Your expression example is incomplete so cannot be commented on intelligently.

Roy

v.trader  
#3 Posted : Sunday, November 22, 2009 5:43:46 PM(UTC)
v.trader

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/26/2009(UTC)
Posts: 76
Location: Toronto, Canada

Hi Roy, Alright, I got it. Thanks for your explanation. And yeah, I just realized that I've copied the incomplete formula but I think I can work it out by myself now. Cheers
v.trader  
#4 Posted : Monday, November 23, 2009 10:54:32 PM(UTC)
v.trader

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/26/2009(UTC)
Posts: 76
Location: Toronto, Canada

Hmm.. there is something wrong cuz I just tried typing up a formula and the forum would not display it. Never mind...
mstt  
#5 Posted : Tuesday, November 24, 2009 6:16:58 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

Hi VT

There is private messaging or email if you still need help. rlarsen@quik.co.nz

Roy

Users browsing this topic
Guest (Hidden)
Similar Topics
Need help with PREV function on Highlight (Formula Assistance)
by Leverage 11/4/2013 6:17:00 PM(UTC)
Trying to Remove the PREV Function [RESOLVED] (Formula Assistance)
by lcl 1/22/2006 4:06:11 PM(UTC)
Removal of the PREV function [RESOLVED] (Formula Assistance)
by RUAGOODP 7/21/2005 5:00:31 PM(UTC)
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.