in Search

How to get the Explorer to not reject securities

Last post 04-06-2008, 18:04 by wabbit. 5 replies.
Sort Posts: Previous Next
  •  04-05-2008, 11:49 26861

    How to get the Explorer to not reject securities

    When you use this formula: (ROC(C,260,%)+ROC(C,130,%)+ROC(C,65,%)+ROC(C,22,%))/4 in the Explorer it rejects securities that lack 261 days of data. Is there a way to write something like 

    if there is at least 261 days of data then (ROC(C,260,%)+ROC(C,130,%)+ROC(C,65,%)+ROC(C,22,%))/4
    else if there is at least 131 days of data then (ROC(C,130,%)+ROC(C,65,%)+ROC(C,22,%))/3
    else if there is at least 66 days of data then (ROC(C,65,%)+ROC(C,22,%))/2
    and so on....

    so that short securities would not get rejected?

     

  •  04-05-2008, 19:48 26863 in reply to 26861

    Re: How to get the Explorer to not reject securities

        Try Isdefined(mov(c,20,s)). It will give you "1" if there are 20 periods of data  loaded.
      {Not tested} Post your results. Thanks.
  •  04-06-2008, 7:41 26868 in reply to 26863

    Re: How to get the Explorer to not reject securities

    I tried it and it fails the same way as the underlying function. IsDefined(ROC(CLOSE,260,%)) fails with the message "Error in Column A: Period value out of range in ROC() function." on all securities having 260 days or less and they are rejected.

    There are two reasons why this is not a good thing. First, by rejecting the security outright the Explorer prevents me from calculating some other substitute function for the security that would prevent the security from being rejected. Second, it prevents me from using the exploration to get the complete list of all securities in the folder; if I want this result as well, I need to run a separate exploration that has no rejections.

    Maybe I am not using the function correctly. Any idea?

     

     

  •  04-06-2008, 8:11 26869 in reply to 26868

    Re: How to get the Explorer to not reject securities

    bullenr,

    The IsDefined() function is not going to help you here; you need to use an external function to return a zero value when the ROC() function is undefined.  Read this thread (http://forum.equis.com/forums/permalink/21013/20995/ShowThread.aspx#20995) for more information on what MS is doing.  The MSFL code there might give you an idea on one method that might be suitable for your aims (but very long winded), it will involve you running several explorations.


    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-06-2008, 9:07 26870 in reply to 26869

    Re: How to get the Explorer to not reject securities

    Right, isdefined() is useless. But by some miracle, the below works. It returns N/A when the security is less than 261 days and returns the ROC otherwise. Any idea why this works?

    M:=Ref(C,0)/Ref(C,-LastValue(Min(260,Cum(1))))-1;

    If(Cum(1)<261,0,M);

  •  04-06-2008, 18:04 26871 in reply to 26870

    Re: How to get the Explorer to not reject securities

    Code:
    M:=Ref(C,0)/Ref(C,-LastValue(Min(260,Cum(1))))-1;

    If(Cum(1)<261,0,M);

    Looking at the expression inside the denominator, LastValue(Min(260,Cum(1)); the code is returning the smallest value, Min(), of 260 and the number of bars on the chart, Cum(1), with the LastValue() "converting" the value from a data array to an integer.This number is then used in the Ref() expression to return a value on either; the 261st bar of the chart if there are more than 260 bars, or on the last bar if there are less than 260 bars.

    It's probably not the best explanation, but have a play with some charts with differing amounts of data and see the what happens for yourself.

    It doesn't completely solve the original issue, but you should be gaining more insight into how MS is dealing with the "definition" periods of data arrays.


    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

View as RSS news feed in XML