in Search

How to retrieve the security name in Explorer or System Tester?

Last post 07-30-2008, 1:05 by drums!!. 4 replies.
Sort Posts: Previous Next
  •  06-01-2008, 12:21 27291

    How to retrieve the security name in Explorer or System Tester?

    Hi,

    Explorer runs through once for each security in a given list of securities.  Does anyone know how to test which security is being used on a given run?

    For example I'm trying to find something like SECURITYNAME used below -

    {declare a variable and use a default of 20}
    t := 20;

    {override the default for a list of specific securities}
    t := if(SECURITYNAME = "BHP", 17, t);
    t := if(SECURITYNAME = "MSFT", 14, t);
    {etc etc}

    {return a 1 if the RSI is below our threshold}
    if(RSI(C,2) < t, 1, 0)

    Thanks,

    Stewart

     

  •  06-01-2008, 22:37 27296 in reply to 27291

    Re: How to retrieve the security name in Explorer or System Tester?

    Hi Stewart,

    This can best be achieved using a simple external function.  You can either test the name of the current stock and return a true false answer, or you can create lists of different stocks ans test to see which list the current stock is in.

    The other way to do it is long, ugly and slow; it involves using the Security() function to compare the prices in the current open data file with the prices as described in the Security() function, if they match exactly there is a good chance (but no guarantee) you have found the right stock ticker.

    You don't necessarily need to define every data item (O,H,L,C,V,OI) but it is the surest way to find an exact match; use as many criteria as you actually need, CLOSE and VOLUME might be sufficient?

    Code:
    threshold:=20;
    otherDataC:=security(path to BHP,C);
    otherDataV:=security(path to BHP,V);
    test:=lastvalue(cum((C-otherDataC)<>0)+((V-otherDataV)<>0))=0;
    threshold:=if(test,17,threshold);

    otherDataC:=security(path to MSFT,C);
    otherDataV:=security(path to MSFT,V);
    test:=lastvalue(cum((C-otherDataC)<>0)+((V-otherDataV)<>0))=0;
    threshold:=if(test,14,threshold);

    {etc etc etc.... ugly and slow}

    {return}
    RSI(C,2)<threshold;

    This method is not guaranteed to return the right results... for example, disparities between data files in multiple directories will return erroneous results.


    wabbit Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

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

  •  06-02-2008, 14:23 27309 in reply to 27296

    Re: How to retrieve the security name in Explorer or System Tester?

    Hi Wabbit,

    Thanks so much for your reply.  You listed two possible solutions.  I was going to use your second technique (ie the one you've listed) if I couldn't find a better one.  I don't fully understand your first suggestion though - ie how to use a "simple external function" to "test the name of the current stock and return a true false answer".

    Is a "simple external function" going to be contained in a dll that I'm going to have to code myself in C++ or whatever else, or is it a function that I'd write in MetaStock's Function Builder?

    I look forward to your response.

    Stewart

  •  06-02-2008, 17:59 27310 in reply to 27309

    Re: How to retrieve the security name in Explorer or System Tester?

    Hi again,

    The first solutions involve using external functions, aka add-ons, plug-ins or .dlls.  You can either write these yourself in C/C++, PowerBasic or PASCAL, if you have the MDK (you only need compare the current data symbol with a user provided argument) or have someone do this for you.  This is by far, the best solution.

    Using the MSFL code like shown in a previous post is much slower and if you need to define different levels for an entire exchange, this solution is impractical (and you will probably run out of room to write the whole code anyway!).

    A third solution would be to re-distribute your data in accordance with the required values for the threshold.  If you have a decent data vendor, this would not be too much of an issue, but it means that you will have to maintain multiple lists of stocks which, in my opinion, causes more problems than it solves.


    wabbit Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

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

  •  07-30-2008, 1:05 27648 in reply to 27310

    Re: How to retrieve the security name in Explorer or System Tester?

    Hi Wabbit (and others),

     

    I've been looking around for something similar also and rather than re-inventing the wheel, I was wondering if you are aware of any existing addons that have this kind of functionality included?

     

    Thanks

    Drums

     

View as RSS news feed in XML