CAGR formula translation

Forums ProRealTime English forum ProBuilder support CAGR formula translation

Viewing 11 posts - 1 through 11 (of 11 total)
  • #13470

    How do I translate this to Probuilder language:

    PRT does not like the “^” (power of) symbol.

    Regards

    #13509

    I’m sorry, I spent almost 2 hours doing maths formulas to solve the MathPow being not available in math instructions of the platform.. Didn’t solve the formula because of the fractionnal exponent. Seems that I could calculate something if the ‘nryears’ is below 3 but not above.

    I have just sent a request to PRT dev team to add the MathPow possibility in the language, as it is not the first time i’m stuck with this! 🙁

    If any math genius come here, I’ll be glad to have his opinion 🙂

    #13512

    Ok, I guess I’ve become a PRC-addict, even when I’m away from my trading station I feel the need to come and read what happened since last visit, haha

    Assuming nryears is an integer, how about a recursive approach, for which the number of iterations would depend on the required precision in the end by the user?

    Let’s say to simplify the formula writing that A=equity/startcapital and n=nryears

    and let’s name B = (equity/startcapital)^(1/nryears) = A^(1/n)

    so B^n = A = B * B^(n-1)

    B = A / B ^(n-1)

    and if I use i to rank the iterations from 1 to maximum i desired for sufficient precision and {} for index:

    B{rank i+1} =  ( B{rank i} + B{rank i} ) / 2

    B{rank i+1} =  ( B{rank i} + A / (B{rank i} ^(n-1) ) / 2

    and a code with 2 loops to use the formula:

    something like:

     

    However, I can’t launch prt and test it from here, so it’s probably bugged as I often need to make changes to first writing before getting it right… Also, I have never tried a loop inside a loop in PRT before, don’t know if it can handle it.

     

    1 user thanked author for this post.
    #13516

    @Nicolas, I could not solve it either. But, I did come up with the following “indicator” – that can be added to the end of any strategy backtesting code.

    It calculates yearly and monthly returns, and looks like this (see attachment).

    I would appreciate any comments or suggestions for improvements.

     

    Regards

    Stef

     

    1 user thanked author for this post.
    #13522

    @Noobywan. Tx, will try it.

    #13525

    @Noobywan

    Your code is good. It successfully returned the good value for the Wikipedia example attached.

    Here is the code with the same value:

    Well done! Fractional exponent gimme headache yesterday, you desserve a beer again! 🙂 Maybe I’ll add a post in the Blog in your own name.

    #13555

    @Stef

    You add the code about monthly and yearly returns in the Library, but I don’t see any code of ITF file attached to your post. Could you please, gimme here? Thanks.

    #13576

    Here you go…

    1 user thanked author for this post.
    #14037

    No problem for blog post if you think it can be useful to compensate for the lack of mathpow, with or without my name doesn’t matter, I don’t own the rights to recursivity

    I am going to write a “carte de fidélité – bières” with squares to stamp the beers on, in case some day I happen to drive near your headquarters 😉

    #14038

    Ahaha noobywan, you just have changed my mood from dark to hilarious, thanks a lot. Always got beers at Nicolas’HQ, no worries 😂

    #98204

    codeforpower = exp(5*log(2))                 //                result = 32 = 2^5
    codeforlogarithm = log(32) / log (2)               //                result = 5

    1 user thanked author for this post.
Viewing 11 posts - 1 through 11 (of 11 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login