function calculateAverage() {
// Get input values
var currentSharesInput = document.getElementById('currentShares');
var currentAvgCostInput = document.getElementById('currentAvgCost');
var newSharesInput = document.getElementById('newShares');
var purchasePriceInput = document.getElementById('purchasePrice');
var curShares = parseFloat(currentSharesInput.value);
var curCost = parseFloat(currentAvgCostInput.value);
var newShares = parseFloat(newSharesInput.value);
var buyPrice = parseFloat(purchasePriceInput.value);
// Validation
if (isNaN(curShares) || curShares < 0) curShares = 0;
if (isNaN(curCost) || curCost < 0) curCost = 0;
if (isNaN(newShares) || newShares < 0) newShares = 0;
if (isNaN(buyPrice) || buyPrice 0) {
newAverage = totalCost / totalShares;
}
var savings = curCost – newAverage;
// Display Results
document.getElementById('displayNewAverage').innerText = "$" + newAverage.toFixed(2);
document.getElementById('displayTotalShares').innerText = totalShares.toLocaleString();
document.getElementById('displayTotalCost').innerText = "$" + totalCost.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2});
var savingsElement = document.getElementById('displaySavings');
if (savings > 0) {
savingsElement.innerText = "-$" + savings.toFixed(2) + " / share";
savingsElement.style.color = "#27ae60";
} else if (savings < 0) {
// Averaging up
savingsElement.innerText = "+$" + Math.abs(savings).toFixed(2) + " / share";
savingsElement.style.color = "#c0392b";
} else {
savingsElement.innerText = "$0.00";
savingsElement.style.color = "#7f8c8d";
}
document.getElementById('resultsSection').style.display = "block";
}
What is Averaging Down in Stocks?
Averaging down is an investment strategy where an investor buys more shares of a stock they already own after the price has dropped. The goal is to lower the average cost per share of the total holding. By reducing the breakeven point, the investor requires a smaller price recovery to start making a profit on the position.
This calculator helps you determine exactly how many shares you need to buy at a specific lower price to achieve your desired average entry price.
How the Calculation Works
The math behind averaging down is a weighted average calculation. It combines the total value of your existing shares with the total value of the new shares you intend to buy.
The Formula:
New Average = ((Old Shares × Old Price) + (New Shares × New Price)) ÷ (Total Shares)
Example Scenario
Imagine you bought 100 shares of TechCorp at $50.00. The market corrects, and the stock falls to $40.00. You decide to buy 100 more shares.
Initial Investment: 100 shares × $50 = $5,000
New Investment: 100 shares × $40 = $4,000
Total Shares: 200
Total Cost: $9,000
New Average Cost: $9,000 ÷ 200 = $45.00
Now, the stock only needs to rise to $45.01 for you to be profitable, rather than the original $50.01.
When Should You Average Down?
While lowering your cost basis is mathematically appealing, it carries risks. This strategy is often referred to as "catching a falling knife" if the fundamental reasons for the stock's decline are serious.
Consider averaging down when:
The company's fundamentals (revenue, earnings, debt) remain strong.
The price drop is due to general market sentiment or overreaction to short-term news.
You have a long-term investment horizon (5+ years).
You are not over-allocating your portfolio to a single stock (risk management).
Risks of Averaging Down
If a stock continues to fall, buying more simply increases your total losses. Always ensure you are not throwing good money after bad. Use this calculator to see how much capital is required to move your average significantly; sometimes the cost to lower the average by a few cents is too high to justify the risk.