Skip to main content
Back to BlogCalculator Guides

How to Calculate Dollar Cost Averaging (and Why DCA Beats Lump Sum Only When Prices Fall)

Calculate dollar cost averaging outcomes — and learn why DCA buys more shares when prices are low, why the average cost per share is total invested divided by total shares not the average price, why lump sum wins in rising markets and DCA wins in falling ones, and why the future projection uses compound interest not price averaging.

The Toolbox TeamAugust 14, 20268 min read

The problem: you have $500 a month, not $18,000 today

You want to buy an asset — an index fund, a stock, a crypto position — and you have two ways in. You could invest $18,000 today (lump sum) and ride whatever the market does. Or you could invest $500 a month for 36 months (DCA) and average your entry price across 36 purchases. The choice sounds like a question of discipline, but it's a question of math: lump sum wins in rising markets because the money is in the market longer; DCA wins in falling markets because later purchases buy more shares at lower prices. The honest move is to calculate both against the same price path and let the numbers decide.

Fastest path

Open the DCA Calculator, type the initial and final prices, recurring amount, frequency, and duration, read the comparison.

Initial price:   $80
Final price:     $220
Recurring:       $250 biweekly for 5 years (130 buys)
Volatility:      ON

→ Total invested:   $32,500
→ Final shares:     268.42
→ Avg cost/share:   $121.07
→ Portfolio value:  $59,053
→ Profit:           $26,553 (81.7%)
→ Lump sum value:   $89,375 (profit $57,125, 175.8%)
→ Lump sum outperformed DCA by $30,322

The tool simulated 130 biweekly purchases along a price path from $80 to $220 with ±15% sinusoidal swings, computed the weighted average cost per share, valued the final portfolio, and compared it to investing the same $32,500 on day 1. In this rising market, lump sum won by $30,322 — because the money was in the market for 5 years instead of dripping in. The rest of this guide is why the average cost per share isn't the average price, why the volatility toggle exists, and why the future projection tab is a different calculation entirely.

The substance: one weighted average, one volatility model, two tabs

Why the average cost per share isn't the average price

The instinct is to add up all the purchase prices and divide by the number of purchases. That's the average price — and it's wrong for your cost basis. The average cost per share is totalInvested ÷ totalShares, which is a quantity-weighted average, not an arithmetic average. The difference matters because you buy different quantities at each price.

At $250 recurring: when the price is $80, you buy 3.125 shares. When the price is $160, you buy 1.5625 shares. The $80 purchase contributes more shares to your total than the $160 purchase, so the $80 price should pull the average down more than the $160 price pulls it up. The weighted average does exactly this: totalInvested ÷ totalShares = $32,500 ÷ 268.42 = $121.07. The arithmetic average of the 130 prices along a linear path from $80 to $220 would be $150 — which would tell you your cost basis is $150, when it's actually $121. The $29 difference is the entire point of DCA: you buy more at the lows, so the lows drag your average down harder than the highs drag it up.

The tool's avgCost = totalInvested / finalShares is the same formula your brokerage reports on a 1099. It's the number that determines whether you have a gain or a loss at the current price — not the arithmetic average of the prices you paid.

The volatility model and why it exists

A linear price path from $80 to $220 is unrealistic — real markets swing. The volatility toggle adds sinusoidal swings of ±15% of the midpoint price: price += Math.sin(t * Math.PI * 4) * amp. The 4 means four full cycles over the duration, so you see four peaks and four troughs between start and end.

The toggle exists because DCA's advantage shows up in the troughs. On a linear rising path, DCA is strictly worse than lump sum — every purchase is at a higher price than the previous one, so your average cost is dragged up by the late purchases, and you'd have been better off buying everything on day 1. Add volatility and the picture changes: the troughs are where you buy the most shares, and if the final price is above your average cost, those trough purchases are the ones carrying your profit. The tool doesn't claim volatility makes DCA win — it shows you whether it does for the specific path you entered.

The DCA vs lump sum comparison

The tool computes both strategies against the same price path and final price:

  • DCA: invest hRecurring at each of N periods, accumulate shares at each price, value the portfolio at the final price.
  • Lump sum: invest N × hRecurring at the initial price, hold, value at the final price.

The badge at the bottom says which won and by how much. In a rising market (final > initial), lump sum almost always wins because all the money captures the full upside. In a falling market (final < initial), DCA almost always wins because the later purchases are at lower prices and the early money didn't get destroyed as badly. In a flat market, it's a wash — the average cost is close to the final price either way.

The math is lumpSumShares = totalInvested / initialPrice and lumpSumFinal = lumpSumShares × finalPrice. Both strategies invest the same total dollars; the only difference is timing. This is why the comparison is apples-to-apples — it isolates the effect of timing, not the effect of investing more or less.

The four frequencies and the per-year factor

The tool supports weekly, biweekly, monthly, and quarterly. Each has a perYear factor: weekly = 52, biweekly = 26, monthly = 12, quarterly = 4. The total number of purchases is perYear × years, so 5 years of biweekly buys is 130 purchases. The days-per-period is used to date each purchase: weekly = 7 days, biweekly = 14, monthly = 30, quarterly = 91.

The frequency doesn't change the math of DCA — it changes the granularity. More frequent purchases mean smaller purchases, which means the average cost tracks the price path more closely. A monthly DCA with $500 buys at 12 prices; a weekly DCA with $115 (roughly the same annual rate) buys at 52 prices. In a volatile market, the weekly DCA captures more troughs and peaks, which gives a slightly lower average cost in most simulations. This is why the tool lets you switch frequencies — the difference is real but small.

The future projection is a different calculation

The Historical tab simulates purchases along a price path. The Future tab projects a portfolio with a fixed annual return — it's compound interest, not DCA. The formula is:

FV = P(1 + i)^n + PMT × [((1 + i)^n − 1) / i]

Where P is the starting principal, PMT is the recurring investment, i is the periodic rate (annual return ÷ per-year), and n is the total periods. The first term is the future value of the principal; the second is the future value of the recurring contributions (an ordinary annuity). The tool computes both iteratively (period by period) and via the closed-form formula, and shows the closed-form result as a check — they match.

The Future tab exists because most DCA investors want to know what the portfolio will be worth in 20 years, not just what the cost basis is. The assumption is a fixed annual return — 8% is the default because it's the historical real return of the S&P 500 after inflation. Change it to match your assumption. The tool's year-by-year table shows start balance, contributions, interest, and end balance for each year, so you can see the year where interest exceeds contributions (usually year 12-15 at 8% — the crossover where compounding takes over).

Gotchas

  • Lump sum wins in rising markets, DCA wins in falling markets. The tool shows you which won for the price path you entered, but it can't predict the path. If you believe markets rise over your horizon (historically true for broad indices over 20+ years), lump sum has the higher expected value. If you believe the market will fall, DCA protects you — but market timing is a losing game.
  • The average cost per share is not the average price. It's totalInvested ÷ totalShares, a quantity-weighted average. The arithmetic average of the prices is the wrong number and will mislead you about your cost basis.
  • The volatility model is sinusoidal, not random. Real price swings are stochastic (fat tails, clustering, sudden drops). The tool's sine-wave volatility is a teaching simplification — it shows the effect of swings, not the distribution of them. Don't treat it as a Monte Carlo simulation.
  • The historical simulator doesn't use real prices. You enter the initial and final prices and the tool interpolates a path. To simulate DCA against an actual asset's price history, you'd need to enter each purchase price manually or use a tool with historical price data.
  • The future projection assumes a fixed annual return. Real returns vary year to year — some years +20%, some years −15%. The tool's 8% default is the long-run average, but the path matters: a −30% year in year 10 of a 20-year projection has a different outcome than a −30% year in year 20, even though the average is the same. The tool can't model sequence-of-returns risk.
  • Frequency changes granularity, not the math. Weekly vs monthly DCA on the same annual rate gives slightly different average costs in a volatile market, but the difference is typically under 1%. Don't optimize frequency — pick the one that matches your paycheck schedule.
  • The comparison assumes you have the lump sum today. If you don't have $18,000 today, DCA isn't a choice — it's the only option. The comparison is for the case where you have the cash and are deciding whether to invest it all at once or drip it in.
  • Taxes and fees are not modeled. The tool's profit number is pre-tax and ignores trading fees. In a taxable account, the lump sum has a larger tax bill if it's a short-term gain; DCA spreads the holding periods, so some shares may qualify for long-term rates earlier than others.

Summary

  • DCA buys more shares when prices are low, fewer when prices are high. The weighted average cost per share (totalInvested ÷ totalShares) is always lower than the arithmetic average of the prices, because the low-price purchases contribute more shares to the total.
  • Lump sum wins in rising markets; DCA wins in falling markets. The tool computes both against the same price path and shows which won and by how much. If you can't predict the market direction (nobody can), the expected-value answer for a rising-tilted asset is lump sum — but DCA reduces regret if the market drops right after you invest.
  • The volatility toggle adds ±15% sinusoidal swings to the linear price path, showing how DCA captures trough purchases. It's a teaching model, not a Monte Carlo simulation — real markets are stochastic with fat tails.
  • The four frequencies (weekly, biweekly, monthly, quarterly) change granularity, not the math. More frequent purchases track the price path more closely, which gives a slightly lower average cost in volatile markets — typically under 1% difference.
  • The Future tab is compound interest, not DCA. FV = P(1+i)^n + PMT × [((1+i)^n − 1) / i]. The first term is the principal's future value; the second is the recurring contributions' future value. The 8% default is the S&P 500's historical real return; change it to match your assumption. The tool computes both iteratively and via closed-form as a check.
  • Simulate at the DCA Calculator; for the compound interest engine use Compound Interest Calculator, for holding-period returns use Investment Returns Calculator, and for long-horizon planning use Retirement Calculator.