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

Notification

Icon
Error

Options
Go to last post Go to first unread
matt678  
#1 Posted : Saturday, January 27, 2007 11:43:34 AM(UTC)
matt678

Rank: Newbie

Groups: Registered, Registered Users
Joined: 1/16/2007(UTC)
Posts: 3

I’m relatively new to Metastock programming, I need to be able to assign a value to a variable and have that variable remain constant until it is reassigned. It seems metastock can only assign code blocks to variables, which is fine except when I need the variable to maintain its value in a function such as value when. I need to code an exploration that will return a value (Such as L, O, C…) of the second most recent occurrence of a high equal to today’s high. The following code won’t work because of how metastock handles variables:

PeriodHigh := H;

ValueWhen(2,H = PeriodHigh, L)

Is there a way to get this code working?
wabbit  
#2 Posted : Friday, February 16, 2007 6:41:52 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)
Hi Matt,

If you are looking for the instances involving TODAY's high, then look at using the LASTVALUE() function. Just remember the dynamic nature of this function - read the users manual for more information.

something like this might help:
ValueWhen(2,H=LastValue(H), L)


wabbit [:D]
Users browsing this topic
Guest (Hidden)
Similar Topics
Global Variable Problem ? (Formula Assistance)
by Gregor 7/25/2011 2:34:44 PM(UTC)
lowest low value bars ago and referencing period as variable problem (Formula Assistance)
by jim_c_hill 11/7/2008 2:44:19 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.