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[
]
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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...
|
|
|
|
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)
|
|
|
|
|
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.