Yearly and monthly returns backtest indicator (for ProBacktest)

Category: Indicators By: Stef Created: September 23, 2016, 7:14 AM
September 23, 2016, 7:14 AM
Indicators
0 Comments

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

// 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)

 

Download
Filename: yearmonthreturn-1.itf
Downloads: 53
Stef Average
I usually let my code do the talking, which explains why my bio is as empty as a newly created file. Bio to be initialized...
Author’s Profile

Comments

Logo Logo
Loading...