in Search

Using a market timing list in Metastock Enhanced System Tester

Last post 04-03-2008, 19:13 by wabbit. 1 replies.
Sort Posts: Previous Next
  •  04-02-2008, 0:55 26836

    Using a market timing list in Metastock Enhanced System Tester

    I have been searching for a way of using market timing lists to buy, sell, sell short and buy to cover in the Enhanced System Tester.

    Have tried various permutations of this but it is both cumbersome and doesn't work.... The market timing list I want to test has more than 50 buy, cash and sell dates....
    -------------------------------------
    BUY

    If((Year()=2005 AND  Month()=10 AND DayOfMonth()=19) OR (Year()=2005 AND Month()=11 and DayOfMonth()=30) OR (Year()=2005 AND Month()=12 AND DayOfMonth()=1) OR (Year()=2005 AND Month()=12 AND DayOfMonth()=16) OR (Year()=2006 AND Month()=4 AND DayOfMonth()=12 OR (Year()=2006 AND Month()=5 AND DayOfMonth()=2)),1,0)

    SELL

    If((Year()=2005 AND  Month()=11 AND DayOfMonth()=30) OR (Year()=2005 AND Month()=12 and DayOfMonth()=14) OR (Year()=2006 AND Month()=4 AND DayOfMonth()=5) OR ((Year()=2006 AND Month()=4 AND  DayOfMonth()=19) OR (Year()=2006 AND Month()=4 AND Month()=5 AND DayOfMonth()=8) OR (Year()=2006 AND Month()=4 AND Month()=5 AND DayOfMonth()=11)),1,0)

    ------------------------

    Thanks!

    Cheers,
    Matt Blackman
  •  04-03-2008, 19:13 26841 in reply to 26836

    Re: Using a market timing list in Metastock Enhanced System Tester

    Hi Matt,

    Welcome to the Forum.

    There are a few ways to tackle this:

    The first is to better organise the logic of your entry and exit dates to make coding and management in MSFL easier, and avoid mistakes.  Try grouping the dates by the longest term factor first i.e. years, then if necessary months, then days, hours, minutes etc.  Also MS returns a boolean value of 1 or 0 depending on whether a condition can be expressed as true or false, so you dont need the If(something,1,0).

    e.g.

    Code:

    {BUY}
    If((Year()=2005 AND  Month()=10 AND DayOfMonth()=19) OR (Year()=2005 AND Month()=11 and DayOfMonth()=30) OR (Year()=2005 AND Month()=12 AND DayOfMonth()=1) OR (Year()=2005 AND Month()=12 AND DayOfMonth()=16) OR (Year()=2006 AND Month()=4 AND DayOfMonth()=12 OR (Year()=2006 AND Month()=5 AND DayOfMonth()=2)),1,0)


    should have the same logic as:

    Code:

    {BUY}

    (Year()=2005 AND
    (Month()=10 AND DayOfMonth()=19) OR
    (Month()=11 and DayOfMonth()=30) OR
    (Month()=12 and (DayOfMonth()=1 or DayOfMonth()=16))
    )
    OR
    (Year()=2006 AND
    (Month()=4 AND DayOfMonth()=12) OR
    (Month()=5 AND DayOfMonth()=2)
    )

    note: this code was written in notepad and untested, so check the right number of brackets etc. but you should get the idea?

    What are these dates?  Is there some pattern to them that could be programmed?  This is much preferred to maintaining a list.


    The second way to do this would be to write an extrnal function to read the dates from a file or other extrnal source.  This would require some extra programming knowledge and the MDK.


    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