EPS and PER indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kei525dow

//@version=4
// Quarterly EPS, PER, total revenue(FQ) (in million unit), PSR can be shown as an indicator.
// Check only one indicator for the chart visibility.

study(title = "EPS REVENUE PSR indicator", shorttitle = "EPS REVENUE PSR")
// basic EPS
BEPS = financial(syminfo.tickerid, "EARNINGS_PER_SHARE_BASIC", "FQ")
DEPS = financial(syminfo.tickerid, "EARNINGS_PER_SHARE_DILUTED", "FQ")
BPER = close / BEPS
DPER = close / DEPS

// PSR
TSO = financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ")
MarketCap = TSO * close
REV_Q = financial(syminfo.tickerid, "TOTAL_REVENUE", "FQ")
PSR = MarketCap / REV_Q / 4
RPS = REV_Q / TSO

// PLOT
plot(BEPS, title="Basic EPS", color=color.red, linewidth=2)
plot(BPER, title="Basic PER", color=color.lime, linewidth=2)
plot(PSR, title="PSR", color=color.blue, linewidth=2)
plot(REV_Q/1e6, title="total revenue(FQ, million unit)", color=color.aqua, linewidth=2)
plot(RPS, title="total revenue(FQ) per share", color=color.green, linewidth=2)

