in Search

Simple time-based calculations in Metastock?

Last post 04-03-2008, 19:43 by wabbit. 2 replies.
Sort Posts: Previous Next
  •  02-06-2008, 11:33 26483

    Simple time-based calculations in Metastock?

    Hi to everyone,

    This is a quick query whether the MS programming code is able to carry out a specific type of time calculation.

    Very simply, if I input a time on which the calculation is to begin, say, 8.10am, and I then want to add a period of time (say, 29mins, 1hr 35mins, etc, etc) to the 8.10am and have a very simple +1 plot on the chart when and where this time period has been calculated, I'm wondering whether MS has the resources to do this relatively simple sounding task.

    The easy part of the code to obtain start times of, say, 8.10am on a specific day is obviously this:

    sm:=Input("starting month",1,12,1);
    sd:=Input("starting day of month",1,31,1);
    sy:=Input("starting year",1980,2100,2008);
    sh:=Input("hour", 1,24,1);
    se:=Input("minute",0,60,0);

    start:= sd=DayOfMonth() AND sm=Month() AND sy=Year() AND sh=Hour() AND se=Minute();

    However, as I stated above I don't know of a way of simply adding, say, 29 minutes to a start time such as 8.10am and I'm wondering whether the MS code has the resources to do this or whether I'd need to create an external dll.

    To those who may be interested, numbers to add to the start such as 29 minutes are square roots of Fibonacci numbers in a simple additive sequence. These square root calculations can be done outside of the MS code and can simply be plugged in later. The main problem is knowing what to do with the code (if it can be done) to add them to selected starting times such as 8.10am.

    The whole thing is pretty easy to create in Excel, but I wanted to do it in Metastock Pro to do some real-time testing on very short term charts (1m ideal). The automated signals that would be produced through the "+1 plot" are much easier to work with than having to move back and forth from Excel to the charts. Besides, if the extension of these square root calculations from daily charts to the intraday timeframe does work (to be determined after sufficient testing), the calculations will need to be automated in any case because they need to be updated throughout the trading day and this is too laborious to do in Excel.

    Thanks in advance if anyone is able to help ...

    Peredur

  •  04-01-2008, 17:15 26834 in reply to 26483

    Re: Simple time-based calculations in Metastock?

        Can you use the BarsSince function? Create a spike (1 or 0) at 8:10, then use
    BarsSince to see if the current period meets  your criteria (if BarsSince(bla bla) = 29
    etc, then do this (yak yak).
    Sorry for not being more specific.

  •  04-03-2008, 19:43 26843 in reply to 26483

    Re: Simple time-based calculations in Metastock?

    Peredur,

    Handling dates and times in MSFL is not impossible, it is just a bit "clunky"  For an example to see how to add three months to a date, see the previous works from a while ago at http://forum.equis.com/forums/permalink/17562/17081/ShowThread.aspx#17081  You should be able to achieve the similar results for time based events as the example shows for calendar based events.

    Personally, I'd implement all of my time based events in external codes, simply because it is easier and much less prone to error, and faster to execute than MSFL.

    Another consideration is to use the OLE capabilities to display the excel chart information in MS.  Read your MS Users Manual for more informationon how to achieve this.


    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