Back to blog
Learn To Invest

Dollar Cost Averaging Formula, With a Worked Example

December 4, 202611 min read
Dollar Cost Averaging Formula, With a Worked Example

The dollar cost averaging formula is: average cost per share = total amount invested ÷ total shares bought, where each month's shares = that month's amount ÷ that month's price. With a fixed amount every month this is the harmonic mean of the prices, so it always lands at or below their simple average, because the same money buys more shares when prices are low. In the real-price example below, $12,000 bought 129.41 shares of VT, an average cost of $92.73 against a simple average price of $93.12.

The formula does not tell you whether DCA beat a lump sum; that depends on what prices did after your first buy. In the VT example monthly buying won by a wide margin, because the price fell hard in 2022 and was back where it started by the end of 2023. Over decades of index data, Vanguard found the lump sum ahead more often than not. The lump sum vs dollar cost averaging calculator runs that comparison for any fund and every start month.

The dollar cost averaging formula

  • Shares bought each time = amount invested ÷ price per share on that day
  • Average cost per share = total amount invested ÷ total shares bought

"Amount invested" is the money that left your account for each purchase, fees included. "Price" is what you paid per share on the day of that purchase. "Total shares" is the sum of every purchase, fractions included if your broker sells fractional shares.

The amounts don't have to be equal: with $500 one month and $800 the next, you still add up the dollars, add up the shares and divide; only the harmonic-mean shortcut in the next section needs equal amounts.

Why your average cost lands below the average price

A fixed amount buys more shares when the price is low and fewer when it is high, so the cheap months carry more weight in your average. Take two buys of $100 each: at $50 a share you get 2 shares, at $100 you get 1. You now own 3 shares for $200, an average cost of $66.67, while the average of the two prices is $75.

With equal amounts, the average cost is the harmonic mean of the prices, and the harmonic mean of positive numbers is never above their ordinary (arithmetic) mean. The two are equal only when the price never moves, and the gap widens as the swings get bigger. A low average cost still doesn't protect you from a loss, since what you own is worth today's price, and today's price can sit below your average cost for months.

Worked example: $500 a month into VT, 2022 to 2023

Say $500 goes into the Vanguard Total World Stock ETF (VT) at every month-end close for two years, so 24 buys and $12,000 in all. Prices are plain closes from Yahoo Finance's VT price history, not adjusted for dividends, with fractional shares and no fees. VT closed January 2022 at $102.51, sank to $78.88 by the end of September 2022 (23% lower) and finished December 2023 at $102.88, so the run catches a whole fall and recovery.

MonthVT close ($)Shares boughtTotal sharesTotal invested ($)Average cost ($)Value ($)
Jan 2022102.514.87764.8776500102.51500.00
Feb 202299.675.01669.89411,000101.07986.15
Mar 2022101.294.936314.83041,500101.141,502.18
Apr 202293.095.371120.20162,00099.001,880.57
May 202293.555.344725.54632,50097.862,389.86
Jun 202285.345.858931.40523,00095.532,680.12
Jul 202291.305.476536.88173,50094.903,367.30
Aug 202287.605.707842.58954,00093.923,730.84
Sep 202278.886.338748.92824,50091.973,859.46
Oct 202283.915.958854.88705,00091.104,605.57
Nov 202290.865.503060.38995,50091.075,487.03
Dec 202286.195.801166.19116,00090.655,705.01
Jan 202392.785.389171.58026,50090.816,641.21
Feb 202389.835.566177.14627,00090.746,930.05
Mar 202392.095.429582.57577,50090.837,604.40
Apr 202393.405.353387.92908,00090.988,212.57
May 202392.275.418993.34798,50091.068,613.21
Jun 202396.985.155798.50369,00091.379,552.88
Jul 2023100.594.9707103.47439,50091.8110,408.48
Aug 202397.735.1161108.590410,00092.0910,612.54
Sep 202393.185.3660113.956410,50092.1410,618.46
Oct 202390.465.5273119.483711,00092.0610,808.49
Nov 202398.615.0705124.554211,50092.3312,282.29
Dec 2023102.884.8600129.414212,00092.7313,314.13

After 24 buys the account held 129.41 shares, so the average cost is 12,000 ÷ 129.41 = $92.73 a share, 0.43% below the $93.12 simple average of the closes (on unrounded prices). Buying the same $12,000 at that average price would have bought 128.86 shares, so the fixed monthly amount picked up 0.55 extra shares, worth about $57 at the final price.

Dollar cost averaging formula in practice: VT monthly close vs running average cost, $500 a month from 2022 to 2023, average cost $92.73 vs $102.51 lump-sum price Data: Yahoo Finance VT price history, month-end closes without dividends; model buys $500 at each close, Jan 2022 to Dec 2023.

The running average cost falls through 2022 as the cheaper months pile up, bottoms at $90.65 in December 2022, then drifts back up to $92.73 because the 2023 buys came in at higher prices. The position still spent 12 of the 24 months under water, the worst of it at the September 2022 low, when the $4,500 put in so far was worth $3,859.46.

At the December 2023 close of $102.88, the 129.41 shares were worth $13,314.13: a gain of $1,314.13, or 10.95% on the $12,000 put in. Dividends paid along the way are not in that figure, since the table uses plain closes. Reinvested, they buy extra shares that compound with the rest and lift the gain to 13.71%.

Did it beat investing the lump sum?

Put the same $12,000 in at the January 2022 close of $102.51 and it buys 117.06 shares, worth $12,043.31 at the end of December 2023. That's a gain of $43.31, or 0.36%, and $1,270.82 behind the monthly buys.

VT, Jan 2022 to Dec 2023$500 a month (DCA)$12,000 in January 2022
Shares owned at the end129.41117.06
Average cost per share$92.73$102.51
Value at the September 2022 low$3,859.46 of $4,500 invested$9,233.83 of $12,000 invested
Value at the December 2023 close$13,314.13$12,043.31
Gain on $12,000+10.95%+0.36%

VT ended December 2023 almost exactly where it started, so every monthly buy below $102.88 made money while the lump sum only climbed back to even. With dividend-adjusted closes the ranking stays the same: DCA +13.71%, lump sum +4.86%.

Vanguard tested the same question on the MSCI World index from 1976 to 2022. A lump sum invested straight away beat cost averaging about two-thirds of the time, and the cost of waiting grew as the averaging period got longer (Vanguard, "Cost averaging: Invest now or temporarily hold your cash?"). On a 60/40 portfolio the lump sum ended 1.8% higher on average than spreading the same money over three months. The same paper notes that cost averaging temporarily lowers risk and can limit the drawdown, and the regret, of buying right before a crash. Vanguard's investor guidance calls delaying a form of market timing.

Money that arrives with each paycheck has no lump sum to compare against, so all of this is about a windfall. If you have one and are tempted to drip it in, set the lump sum vs DCA calculator to the spread you're weighing (3, 6, 12, 24 or 36 months) and it shows how often that spread beat investing at once in your fund, across every start month in its price history. It works on total-return prices with dividends reinvested, so its VT figures come out a little higher than the table's plain closes.

The formula in a spreadsheet

Put the month in column A, the amount invested in column B and the price per share in column C, starting in row 2. Then add these columns and fill each formula down to the last month; they work the same in Excel and Google Sheets.

ColumnWhat it holdsFormula in row 2
DShares bought=B2/C2
ERunning shares=SUM($D$2:D2)
FRunning average cost=SUM($B$2:B2)/E2
GValue at that month's price=E2*C2
HGain or loss=G2/SUM($B$2:B2)-1

For the 24 VT rows above, the final average cost is =SUM(B2:B25)/SUM(D2:D25), which returns 92.73. With equal monthly amounts you can check it with =HARMEAN(C2:C25), also 92.73, and compare it with =AVERAGE(C2:C25), which returns 93.12. The HARMEAN check stops matching as soon as the amounts differ from month to month; the SUM version keeps working.

What fees do to the formula

A per-trade fee is part of the cost: if it comes out of each buy, shares = (amount − fee) ÷ price, and you still divide the full amount that left your account by the shares you got. If your broker charges the fee on top instead, make column B the total that left your account, fee included. Either way, enter each month's fee in the next free column (I2 downwards) and change the shares formula to =(B2-I2)/C2.

The same 24-month VT run with a flat $1 fee on every buy:

Monthly buyFee as % of each buyFees over 24 monthsAverage cost, no feeAverage cost with $1 feeIncrease
$1001.00%$24$92.73$93.66+1.01%
$5000.20%$24$92.73$92.91+0.20%

On $100 buys, the fee adds 1.01% to the average cost, more than twice the 0.43% by which the averaging put the average cost below the simple average price. At $500 a month it shrinks to 0.20%.

US brokers such as Fidelity list $0 commission for online US stock and ETF trades. European brokers often charge per order: DEGIRO charges €1 per trade for ETFs in its core selection on Tradegate and €3 for most others, according to Curvo's breakdown. The fund's own expense ratio (0.06% a year for VT, per Vanguard's fact sheet) is a separate cost, and it is already inside the daily price, so it doesn't go into the formula.

If your broker charges per trade and your monthly amount is small, work out the fee as a percentage of one buy before you set up the order. At $1 on $100, buying every second month with $200 halves the drag to 0.50% and keeps the same yearly total going in. Then check what $500 a month grows to in 10, 20 and 30 years once fees and inflation are taken out.

Frequently asked questions

How do you calculate dollar cost averaging?
Divide each purchase amount by that day's price to get the shares it bought, add up all the shares, then divide the total amount invested by the total shares. With $500 a month into VT from January 2022 to December 2023, $12,000 bought 129.41 shares, an average cost of $92.73. In a spreadsheet, =SUM(B2:B25)/SUM(D2:D25) does it, with column D holding =B2/C2.
Is the average cost the same as the average price?
No. With a fixed amount per purchase, the average cost is the harmonic mean of the prices, which is never higher than their simple average and equal only if the price never moves. Over 24 months of VT closes from 2022 to 2023 the average cost was $92.73, 0.43% below the simple average price of $93.12 (on unrounded prices), because the same $500 bought more shares in the cheap months.
Does dollar cost averaging work?
It works as a way to invest money as it arrives, and it lowers your average cost below the average price. It does not reliably beat investing a lump sum at once: Vanguard's study of the MSCI World from 1976 to 2022 found the lump sum ahead about two-thirds of the time. In VT from January 2022 to December 2023 DCA won, +10.95% against +0.36%, because the price fell 23% and then recovered.
Can you use dollar cost averaging when selling?
Yes, but selling a fixed dollar amount each month sells more shares when the price is low, so your average sale price is the harmonic mean, the lower figure. On the same 24 VT closes, selling $500 a month averages $92.73 a share, while selling a fixed number of shares each month averages $93.12. For withdrawals, selling a fixed number of shares avoids that.

Free Financial Tools

Stay updated

Get notified when we publish new articles.

Related posts