Annual percentage returns
Forums › ProRealTime English forum › ProOrder support › Annual percentage returns
- This topic has 3 replies, 2 voices, and was last updated 5 years ago by Vonasi.
-
-
03/14/2019 at 5:01 PM #93661
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.
12345678910111213141516capital = 10000once lastcapital = capitalrunningperc = ((strategyprofit - laststrategyprofit) / lastcapital) * 100if year <> year[1] thenannualreturn = runningperc[1]laststrategyprofit = strategyprofitlastcapital = capital + strategyprofitendifalltime = (strategyprofit / capital) * 100graph 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"03/14/2019 at 5:07 PM #93664I thought that I would add an average of the annual percentage returns. Not tested but should work.
1234567891011121314151617181920capital = 10000once lastcapital = capitalrunningperc = ((strategyprofit - laststrategyprofit) / lastcapital) * 100if year <> year[1] thenannualreturn = runningperc[1]laststrategyprofit = strategyprofitlastcapital = capital + strategyprofittotal = total + annualreturncount = count + 1annualaverage = total/countendifalltime = (strategyprofit / capital) * 100graph 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 %"03/14/2019 at 9:01 PM #93698Thank you for sharing, I have added to here
03/14/2019 at 9:56 PM #93710Thank you for sharing, I have added to here
I thought you might! 🙂
-
AuthorPosts