# Annually Compounding Growth Rate

Hi all,
How to calculate and program CAGR, if during this time I put in and take out some extra capitals?
Thanks,
Maury

Just donâ€™t put in/out money and that is it.

What if it is my 401k, and me and company put in some money every month?

You need to decide if you want to calculate something that interests you (like CAGR) or if you want to do â€śvirtual realityâ€ť. If you are interested in getting job done, you just run backtest and be done. Start with high enough initial equity so all trades are taken and look at the result and thatâ€™s it. If you have too much free time you can tweak your calculations, export the equity (or use ~~~EQUITY) and do whatever calculation you need. If you have even more time you can write your custom backtest code that will add cash to your account every month or every other period. You can derive your own method of calculation and add it as custom metric.

Sorry, my question was very simple.
What will be my initial capital to calculate CAGR, in my case of 401K, when I and company put some money every month? Is it the beginning capital in Jan, or I have to calculate by each month and then aver?
Thanks,
Maury

@maury314: Are you trying to report the CAGR of your trading system (which will approximately the same regardless of cash deposits and withdrawals), or the CAGR of your account, which will be very much affected by deposits and withdrawals?

In either case, do you already understand how to calculate CAGR from an equity curve? If you donâ€™t have a firm grasp of the math, then it will be impossible to write the AFL.

Annually Compounding Annual Growth Rate
ACAGR = RatioCycles â€“ 1
Ratio = EndValue / StartValue
Cycles = 1 / DateRangeInYears
DateRangeInYears = (EndDate â€“ StartDate) / 365.25

Equity From ACAGR
Equity = OriginalEquity * (1 + ACAGR) (DateRangeInYears)

So â€¦ What should be equal to StartValue in my case (deposit every month and withdraw some time) with for my accounts?

Sorryâ€¦ Ratio^^Cycles

Right. So what about my first question: are you trying to calculate CAGR for the account, i.e. cash deposits and withdrawals will be considered similarly to trading gains and losses? Or are you trying to calculate CAGR for the trading system only, independent of cash deposits and withdrawals?

â€¦ Account â€¦

@maury314 If you want to calculate your account cagr while occasionally making additions and subtractions from the account then you will need to make complex mathematical calculations and code them into the Custom Backtest Interface. I suspect both steps are beyond your capabilities (not meant as an insult as they are beyond mine too). You can start by reading this http://www.financialwisdomforum.org/gummy-stuff/xirr.htm

and investigating the Excel function "XIRR" which has a formula that looks similar to this,

There are simpler approximations but they too require a fair bit of calculations and code writing.

Have you reached the stage that your trading strategies are so solid that you can spend your time doing these calculations as opposed to just keeping track of your overall portfolio growth (or shrinkage) ?

3 Likes

Thanks Larry, finally I got the answer.

Some my response â€¦

I am using Roger Scott Market Geeks service.

You are not insulting me â€¦ . I understand and like the Excel function â€¦ I have PHD in math, but it was long time ago. My problem is that I donâ€™t know object programming in a good level and my beautiful but bad Russion English , that cannot explain a good and fast way to people â€¦