Your numbers
What it says
Ready to go further
Next: how a DCA bot behaves when price keeps falling
The calculator treats the prices as given. A bot decides its buys from the price, which changes the risk.
What is included
- The calculator, with your own numbers
- The formula written out
- A worked example you can reproduce
- Where grid, martingale and DCA bots break the maths
Who it is for
- People running or testing a trading bot
- Anyone sizing a position or checking costs
- Readers learning how the numbers work
- Not advice, and not for placing trades
Key facts
- Dollar cost averaging (DCA) means buying a fixed dollar amount again and again, whatever the price.
- A fixed amount buys more units when price is low and fewer when it is high, so the average cost is the harmonic mean of the prices, never above the simple average.
- DCA does not remove the risk of a falling asset. A fall means you bought more units on the way down.
- DCA investing usually adds fresh money on a schedule. A DCA bot often adds only when price falls, which is a different rule with more exposure.
- All price series on this page are made up. The calculator cannot tell you where price goes next.
How the calculator works
Each buy spends the same dollar amount, so it buys amount / price units. Add the units up, divide the total spent by the total units, and you have the average cost.
Total units = sum of (amount / price) over all buys
Average cost = total spent / total units = n / (1/p1 + 1/p2 + ... + 1/pn)
Value = total units x last price
The last form is the harmonic mean of the prices. It is always at or below the simple average, because low prices get more units and so carry more weight. Order does not matter: the same five prices in reverse give the same average cost.
A worked example
Take five made-up buys of $100 at prices of $100, $90, $80, $95 and $110. They buy 1.0000, 1.1111, 1.2500, 1.0526 and 0.9091 units, a total of 5.3228 units for $500. The average cost is 500 / 5.3228 = $93.93, below the simple average of $95.00. At the last price of $110 the units are worth $585.51, a gain of $85.51 or 17.1 percent. One $500 buy at the first price of $100 would be 5 units, worth $550 at $110, a gain of 10.0 percent. In this series the repeated buys finished ahead.
The same maths in a falling market
Now take prices of $100, $90, $80, $70 and $60, still $100 a time. The average cost is $77.44, and at $60 the 6.4563 units are worth $387.38. That is a loss of $112.62 or 22.5 percent. One $500 buy at $100 would have lost 40.0 percent. The repeated buys lost less, but both lost. And the more it fell, the more units were bought and the more was spent on the way down.
The same five prices in rising order, $60 to $100, give the same average cost of $77.44. Here the repeated buys gain 29.1 percent, while one $500 buy at $60 would gain 66.7 percent. Which approach finishes ahead depends entirely on the path that happens.
DCA investing is not the same as a DCA bot
The word DCA covers two quite different things, and the calculator above is neutral about both.
- Scheduled buying. The same amount goes in on a calendar, whatever the price. The total spent is known in advance, and a falling asset does not make the plan buy more dollars.
- A DCA bot. Many bots add to a position only after price falls by a set amount, often with larger orders at lower levels. The total spent depends on how far price falls, so the exposure grows exactly when the position is losing. That is the averaging down arithmetic, and with growing order sizes it becomes a martingale ladder.
- Costs. Each buy pays a fee and spread, so many small buys pay more in total than a few large ones. Add them to the price you enter.
The DCA bot guide covers how the bot version works, what it needs to be safe, and how it fails.
Keep Going
Related Tools and Guides
Keep exploring
FAQ
Frequently Asked Questions
Is average cost the simple average of the prices?
No. With equal dollar amounts it is the harmonic mean, which is always at or below the simple average. In the first example the simple average is $95.00 and the average cost is $93.93.
Does DCA beat one big buy?
Not as a rule. In a falling series it loses less, in a rising series it gains less. Either way the result depends on the path, which nobody knows in advance.
Why do prices at the first and last position matter?
The comparison uses the first price for the single buy and the last price to value everything. Change either end of the list and the answer can reverse.
Can I use buys of different sizes?
Not in this version: it assumes the same dollar amount each time. To model larger buys at lower prices, use the average down calculator.
What goes wrong with a DCA bot in a long fall?
It keeps buying and the total spent keeps rising, so exposure grows as the position loses. The question is whether the account and margin can hold the largest position the bot can reach.
Are the numbers on this page real?
Example numbers are made up to show how the maths works, and the page says so. A figure only counts as exact when the page says it was calculated on a stated date. Nothing you enter in a calculator leaves your browser.
Can I use this to decide whether to run a bot?
It can show whether a bot's numbers hold together and how much an account can lose. It cannot say what the market will do, and it is not advice. Use it to ask better questions, then read the terms of your own broker or exchange.
Is this financial advice?
No. It is a calculator and general education. It does not consider your situation, and its output is only as good as the numbers you enter.
Know the Risk Before You Run It
Free calculators and guides, added every week. Leave your details and we will email you when new ones go up.
Trading carries a risk of loss