OPEN-SOURCE SCRIPT
HashCost - Bitcoin Mining Cost

HashCost estimates the electricity or hosting energy cost of producing one Bitcoin using a user-defined mining fleet.
Unlike a generic network-wide mining-cost model, HashCost is built around the miner's own operating history. Users enter dated fleet configurations containing effective hashrate, average paid power, electricity cost, and pool fee. Each configuration takes effect on its specified date, while previous configurations remain intact, allowing the plotted production-cost history to reflect changes in the user's mining setup over time.
HOW IT WORKS
HashCost combines the active fleet configuration with Bitcoin network difficulty and block subsidy data to estimate the expected BTC production per day.
Production Cost = Daily Paid Energy Cost / Expected Net BTC per Day
The model uses:
- Effective hashrate in TH/s
- Average paid power in kW
- Electricity or hosting-energy rate in USD/kWh
- Pool fee
- Bitcoin network difficulty
- Bitcoin block subsidy
Effective hashrate and paid power are entered as 24-hour averages. This makes it possible to represent miners who operate for only part of each day.
For example, a 300 TH/s miner consuming 6 kW for 8 hours per day can be represented as:
100 TH/s effective hashrate
2 kW average paid power
FLEET HISTORY
Each line represents one complete mining configuration:
YYYY-MM-DD | Effective TH/s | Avg Paid kW | $/kWh | Pool %
Example:
2026-01-01 | 1000 | 20 | 0.05 | 1
Add a new line whenever the mining setup changes. Keep previous lines in chronological order from oldest to newest.
HashCost preserves those historical configurations rather than retroactively applying the latest settings to the entire chart.
NETWORK DATA
Bitcoin difficulty and block-height data are sourced from Glassnode's crypto metrics on TradingView.
HashCost checks the freshness of the underlying network data and fails closed if the selected source becomes stale rather than silently continuing to calculate with outdated forward-filled values.
INFO PANEL
BTC Cost
Estimated energy production cost of one BTC.
BTC vs Cost
Percentage difference between current BTC market price and estimated production cost.
BTC / Day
Expected net BTC production per day after the entered pool fee.
Cost / Day
Average paid electricity or hosting energy cost per day.
Eff. Hashrate
Effective 24-hour mining hashrate.
SCOPE AND LIMITATIONS
HashCost is an electricity/hosting-energy operating-cost model. It is not an all-in accounting cost model.
It does not include hardware purchase cost, depreciation, repairs or maintenance, financing, taxes, labor, rent, or other expenses unless already incorporated into the entered energy rate.
Transaction-fee revenue is excluded.
HashCost is intended for standard 1D Bitcoin charts quoted in USD or supported USD-like markets such as USDT, USDC, and FDUSD.
It is a mining production-cost analysis tool, not a trading signal or price prediction.
Unlike a generic network-wide mining-cost model, HashCost is built around the miner's own operating history. Users enter dated fleet configurations containing effective hashrate, average paid power, electricity cost, and pool fee. Each configuration takes effect on its specified date, while previous configurations remain intact, allowing the plotted production-cost history to reflect changes in the user's mining setup over time.
HOW IT WORKS
HashCost combines the active fleet configuration with Bitcoin network difficulty and block subsidy data to estimate the expected BTC production per day.
Production Cost = Daily Paid Energy Cost / Expected Net BTC per Day
The model uses:
- Effective hashrate in TH/s
- Average paid power in kW
- Electricity or hosting-energy rate in USD/kWh
- Pool fee
- Bitcoin network difficulty
- Bitcoin block subsidy
Effective hashrate and paid power are entered as 24-hour averages. This makes it possible to represent miners who operate for only part of each day.
For example, a 300 TH/s miner consuming 6 kW for 8 hours per day can be represented as:
100 TH/s effective hashrate
2 kW average paid power
FLEET HISTORY
Each line represents one complete mining configuration:
YYYY-MM-DD | Effective TH/s | Avg Paid kW | $/kWh | Pool %
Example:
2026-01-01 | 1000 | 20 | 0.05 | 1
Add a new line whenever the mining setup changes. Keep previous lines in chronological order from oldest to newest.
HashCost preserves those historical configurations rather than retroactively applying the latest settings to the entire chart.
NETWORK DATA
Bitcoin difficulty and block-height data are sourced from Glassnode's crypto metrics on TradingView.
HashCost checks the freshness of the underlying network data and fails closed if the selected source becomes stale rather than silently continuing to calculate with outdated forward-filled values.
INFO PANEL
BTC Cost
Estimated energy production cost of one BTC.
BTC vs Cost
Percentage difference between current BTC market price and estimated production cost.
BTC / Day
Expected net BTC production per day after the entered pool fee.
Cost / Day
Average paid electricity or hosting energy cost per day.
Eff. Hashrate
Effective 24-hour mining hashrate.
SCOPE AND LIMITATIONS
HashCost is an electricity/hosting-energy operating-cost model. It is not an all-in accounting cost model.
It does not include hardware purchase cost, depreciation, repairs or maintenance, financing, taxes, labor, rent, or other expenses unless already incorporated into the entered energy rate.
Transaction-fee revenue is excluded.
HashCost is intended for standard 1D Bitcoin charts quoted in USD or supported USD-like markets such as USDT, USDC, and FDUSD.
It is a mining production-cost analysis tool, not a trading signal or price prediction.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.