Annual percentage returns

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #93661 quote
    Vonasi
    Moderator
    Master

    Sometimes we code a strategy and it looks great but in reality the rewards might be lower than if we invested the money elsewhere. Why put money in a high risk strategy that returns just 3% per annum when you could get 4% somewhere else with lower risk? So I thought that I would code something that could be added to any strategy and so display the previous years overall return in percentage as well as the all time profit to date in percentage as well as a running profit for the current year so far in percentage.

    I thought that I would share it just in case it is helpful to anyone else.

    capital = 10000
    
    once lastcapital = capital
    runningperc = ((strategyprofit - laststrategyprofit) / lastcapital) * 100
    
    if year <> year[1] then
    annualreturn = runningperc[1]
    laststrategyprofit = strategyprofit
    lastcapital = capital + strategyprofit
    endif
    
    alltime = (strategyprofit / capital) * 100
    
    graph runningperc coloured(0,128,0) as "Running % Return"
    graph annualreturn coloured(0,0,150) as " Last Years Annual % Return"
    graph alltime coloured(128,145,150) as "All Time % Return"

    [attachment file=93662]

    #93664 quote
    Vonasi
    Moderator
    Master

    I thought that I would add an average of the annual percentage returns. Not tested but should work.

    capital = 10000
     
    once lastcapital = capital
    runningperc = ((strategyprofit - laststrategyprofit) / lastcapital) * 100
     
    if year <> year[1] then
    annualreturn = runningperc[1]
    laststrategyprofit = strategyprofit
    lastcapital = capital + strategyprofit
    total = total + annualreturn
    count = count + 1
    annualaverage = total/count
    endif
     
    alltime = (strategyprofit / capital) * 100
     
    graph runningperc coloured(0,128,0) as "Running % Return"
    graph annualreturn coloured(0,0,150) as " Last Years Annual % Return"
    graph alltime coloured(128,145,150) as "All Time % Return"
    graph annualaverage coloured(0,0,0) as "Annual Average %"
    #93698 quote
    GraHal
    Participant
    Master

    Thank you for sharing, I have added to here 

    Snippet Link Library

    #93710 quote
    Vonasi
    Moderator
    Master

    Thank you for sharing, I have added to here

    Snippet Link Library

    I thought you might! 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Annual percentage returns


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Vonasi @vonasi Moderator
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Vonasi
6 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/14/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...