OPEN-SOURCE SCRIPT
已更新

PE Bands w/ Persistent EPS Proxy

153
This Pine Script is a valuation overlay for any stock or index, built around the idea of tracking and projecting P/E (Price-to-Earnings) multiple bands using trailing EPS and a growth assumption. Here's a full breakdown:

🔍 Purpose:
To visualize price bands based on valuation multiples (like 16x, 18x, 20x, etc.) of forward EPS, estimated from actual reported EPS over the last 4 quarters.

🧱 Core Components:
version=6
Specifies the latest Pine Script version (v6), ensuring compatibility with the newest syntax.

✅ indicator(...)
Declares a chart overlay indicator titled 'PE Bands w/ Persistent EPS Proxy', meaning the plots will appear on top of the price chart.

1. 📈 Growth Assumption Input
pinescript
Copy
Edit
Growth = input.float(1.08, 'Growth')
User input for projected forward EPS growth (default: +8%). This models earnings growth from trailing 12 months to forward 12 months.

2. 🧮 Retrieve EPS Data
pinescript
Copy
Edit
epsRaw = request.earnings(syminfo.tickerid, earnings.actual, gaps = barmerge.gaps_off)
Uses the built-in request.earnings() function to fetch actual EPS.

Works with any symbol that supports earnings data.

barmerge.gaps_off ensures EPS only shows on report bars (not filled in between).

3. 🧠 Persistent Memory for Last 4 EPS Values
pinescript
Copy
Edit
var float eps1 = na
...
if not na(epsRaw)
eps4 := eps3
eps3 := eps2
eps2 := eps1
eps1 := epsRaw
Implements a shift register: keeps track of the last 4 quarterly EPS values, so it can compute a full TTM (trailing 12-month) EPS even though epsRaw only updates quarterly.

4. 📊 Trailing 12-Month EPS
pinescript
Copy
Edit
epsTTM = na(eps1) or na(eps2) or na(eps3) or na(eps4) ? na : eps1 + eps2 + eps3 + eps4
Sums the most recent 4 quarters to get a TTM earnings proxy.

If any value is still na, the result is na.

5. 🔮 Forward EPS Estimation
pinescript
Copy
Edit
fwdEPS = epsTTM * Growth
Projects forward EPS using a growth multiplier (1.08 = +8%).

You could customize this to vary over time (e.g., macro-modelled growth).

6. 📐 Valuation Bands
pinescript
Copy
Edit
pe16 = fwdEPS * 16
...
pe24 = fwdEPS * 24
Calculates price levels the stock/index would be trading at under different valuation multiples of forward EPS.

These become bands: 16x, 18x, 20x, etc.

7. 📉 Plot Bands
pinescript
Copy
Edit
plot(pe16, ...)
...
plot(pe24, ...)
Draws horizontal or sloped bands that reflect valuation ranges.

If SPX is above the 22x or 24x band, you might consider the market overvalued.

If it’s near 16x, potentially undervalued (depending on forward EPS quality).

✅ Summary:
This is a dynamic, earnings-based valuation overlay for use on equity or index charts. It uses:

Real EPS data (as it gets reported)

Persistent memory to calculate trailing 12M EPS

Growth modeling to estimate forward EPS

Price targets for different forward P/E multiples
發行說明
adding ticker

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。