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

Notification

Icon
Error

Options
Go to last post Go to first unread
cji82  
#1 Posted : Sunday, April 13, 2008 11:43:13 AM(UTC)
cji82

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 3/3/2008(UTC)
Posts: 2

Hi,

I try to write a pivotal point detect function. The detection is actually a state machine. There are 6 states in the state machine. The state changes according to the daily price. It decide which state it is and store today's close price in different state according to some rules. I need to store the state ID and the last recorded price in each state. That will be refered by next day caculation.

As I know, the MetaStock formula language privides the variables. But the variable is different to the one in C language. It can not keep the last value in previous caculation.

I don't think to scan the data from begin to current date in each caculation is a good idea. So, I need to ask if any possible to achieve my requirment? (To store the variable of previous calculation)

Thank you.

wabbit  
#2 Posted : Sunday, April 13, 2008 7:18:25 PM(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 cji82,

Welcome to the Forum.

There are a couple of things here; the first is to have a look at the work already posted on the forum regarding pivots, some of this uses the PowerPivots addon but a lot of it doesn't. Maybe these will offer a different perspective on the problem, and an alternative solution.

The next is to read up on the PREV function, which is a recursive function that can be used to store a previous value (hence the term PREV!) One problem with PREV is that is causes a dramatic drain on CPU resources and is very slow to return a result because of its recursion.

Depending on how the code you want is written, it MIGHT be possible to employ Ref() or ValueWhen() functions to return different values; it might also be possible to employ Mark Pyle's global variable library of functions (GV.dll) which is available in the downloads section. You will have to some more research on these.

Ultimately, to overcome the limitations of the native MetaStock Formula Language, you could write your own external function library after purchasing the MetaStock Developers Kit.


Hope this helps.

wabbit [:D]
cji82  
#3 Posted : Monday, April 14, 2008 12:45:21 AM(UTC)
cji82

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 3/3/2008(UTC)
Posts: 2

Hi wabbit:

I think the global variable is exactly what I need. I will study the GV.dll.

Thanks for your help.

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.