This ProBuilder script is designed to calculate and display the annual percentage return, the cumulative return since the inception of the strategy, and the running percentage return for the current year. These metrics are crucial for evaluating the performance of a trading strategy over different time frames.
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"
Explanation of the Code:
lastcapital variable is also initialized with this value, but only once, to keep track of the capital at the start of each year.runningperc variable calculates the percentage return based on the profit or loss since the last recorded strategy profit. This gives a real-time update on how the strategy is performing in the current year.laststrategyprofit and lastcapital to reflect the strategy’s performance and new capital at year-end.alltime variable calculates the total percentage return of the strategy from its inception relative to the initial capital.graph functions to visually display the running percentage return, last year’s annual return, and all-time return on the chart. Each graph is color-coded for clear differentiation.This script is a useful tool for traders and analysts to monitor and evaluate the performance of their trading strategies over different periods, providing clear, visual feedback directly on the trading charts.
Check out this related content for more information:
https://www.prorealcode.com/topic/annual-percentage-returns/#post-93661
Visit Link