in Search

State machine

Last post 04-14-2008, 0:45 by cji82. 2 replies.
Sort Posts: Previous Next
  •  04-13-2008, 11:43 26941

    State machine

    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.

  •  04-13-2008, 19:18 26943 in reply to 26941

    Re: State machine

    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 Big Smile [:D]

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status : wabbit.com.au SkyPE online status
    My SkyPE account : wabbit.com.au

  •  04-14-2008, 0:45 26952 in reply to 26943

    Re: State machine

    Hi wabbit:

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

    Thanks for your help.

     

     

View as RSS news feed in XML