in Search

Can anyone program a cumulative product function?

Last post 11-07-2009, 20:52 by exito100. 5 replies.
Sort Posts: Previous Next
  •  11-06-2009, 22:40 31121

    Can anyone program a cumulative product function?

    Is there a way to program in Metastock Formuar language a product of all e.g. closing values without a prev function?

    product:=value1*value2*value3....*last value

    for example as in:

    product:=C*PREV;

    is very slow.

    In other words I am looking for the product equivalent of the cum() function.

    I keep looking and trying.. but if someone figures this out earlier please post here! :)

    Many thanks,

    Klaus
  •  11-07-2009, 7:14 31123 in reply to 31121

    Re: Can anyone program a cumulative product function?

    you may try:

    exp(sum(log(close),lastvalue(cum(1))));

    btw how much ram does your computer have?
  •  11-07-2009, 9:03 31126 in reply to 31123

    Re: Can anyone program a cumulative product function?

    Thanks wblam! Brilliant idea to use the sum of logs...! Should have thought of that earlier :) Too tired to test it now though. My notbook has only 256MB so that is certainly an issue I guess. Does anyone have an idea if extra ram can speed up these kind of calcluation significantly. Would doubling the Ram roughly double the speed? Thanks for the idea, Klaus
  •  11-07-2009, 18:11 31130 in reply to 31126

    Re: Can anyone program a cumulative product function?

    Assume that close=10 and you load 200 days of data.
    The answer will be 10 to the power of 200!
    I do not think MS or your computer can handle it.
  •  11-07-2009, 18:25 31131 in reply to 31126

    Re: Can anyone program a cumulative product function?

    Giorgos' answer in here is more correct:

    http://tradersconsortium.com/community/index.php?showtopic=24533&pid=26963&st=0&#entry26963
  •  11-07-2009, 20:52 31137 in reply to 31130

    Re: Can anyone program a cumulative product function?

    Fortunately I don't really want to multiply closing prices every bar - this was just an example, of course. For what I need it, the above solution works fine with me.
View as RSS news feed in XML