This “indicator” can be added to the end of any strategy’s code to show yearly and monthly returns.
This is a nice way to quickly see your strategy’s performance over time with regards to profitability; good/bad months/years.
At the moment (v10.2) PRT backtest statistics do not provide this information.
Would appreciate some comments and suggestions for improvements.
Stef
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
// yearly and monthly returns once startcapital=100000 // initial capital amount once yearstartcap=startcapital // set initial capital for 1st year once mstartcap=startcapital // set initial capital for 1st month if day<day[1] and month=1 then // new year endcapital=startcapital+strategyprofit // ending capital for the year (previous year) prof=endcapital-yearstartcap // profit for the year (previous year) yearstartcap=endcapital // set starting capital for the new year yearreturn=(prof/startcapital)*100 // yearly return as percentage (previous year) endif if day<day[1] and month>month[1] then // new month mendcapital=startcapital+strategyprofit // ending capital for the month (previous month) mprof=mendcapital-mstartcap // profit for the month (previous month) mstartcap=mendcapital // set starting capital for the new month mreturn=(mprof/startcapital)*100 // monthly return as percentage (previous month) endif graph 0 coloured(0,0,255) // graph zero line graph yearreturn coloured(0,200,0) as "Yearly Return %" // graph yearly return (prev year) graph mreturn coloured(154,0,154) as "Monthly Return %" // graph monthly return (prev month) |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials