Book Value Per Share Overlay
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Eur0pa

//@version=5
indicator("BVPS", overlay=true)

// Define inputs
//total_assets = input.float(title="Total Assets", defval=0)
//total_liabilities = input.float(title="Total Liabilities", defval=0)
//num_shares = input.float(title="Number of Shares", defval=0)

// //Formula:
// //Book value per share = Total common equity / Total common shares outstanding
// TSO = request.financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ")
// TTA = request.financial(syminfo.tickerid, "TOTAL_ASSETS", "FQ")
// TTL = request.financial(syminfo.tickerid, "TOTAL_LIABILITIES", "FQ")
// TCE = request.financial(syminfo.tickerid, "COMMON_EQUITY_TOTAL", "FQ")

// // Calculate book value per share
// book_value_per_share = (TTA - TTL) / TSO
// BVPS = (TCE) / TSO
BVPS=request.financial(syminfo.tickerid,"BOOK_VALUE_PER_SHARE","FQ")
PriceBookRatio =close /BVPS

// Display book value per share on chart
plot(BVPS, color=color.aqua, linewidth=2, title="Book Value per Share")
//plot(book_value_per_share, color=color.blue, linewidth=2, title="Book Value per Share")
//plot(PriceBookRatio, color=color.lime, linewidth=2, title="Price Book Ratio")
