OPEN-SOURCE SCRIPT

Forward P/E

已更新
The Forward P/E indicator calculates and visualizes the forward price-to-earnings (P/E) ratio of a stock based on its most recent quarterly earnings per share (EPS) and the current market price.

Key Features:
  • Quarterly EPS Data: The script retrieves the diluted EPS for the most recent fiscal quarter (FQ) of the selected stock using financial data.
  • Annualized EPS: The quarterly EPS is multiplied by four to estimate the annualized EPS, assuming consistent earnings throughout the year.
  • Forward P/E Calculation: The forward P/E is derived by dividing the stock's current closing price by its annualized EPS.
  • Visualization: The calculated forward P/E ratio is plotted for easy interpretation.
  • Reference Line: An optional horizontal reference line at 0 helps quickly identify when the P/E ratio becomes invalid or potentially negative due to anomalies in EPS data.


This tool is useful for investors and traders seeking to evaluate a stock's valuation relative to its projected earnings, helping identify potentially overvalued or undervalued opportunities.
版本注释
The Forward P/E with Median indicator calculates and visualizes the forward price-to-earnings (P/E) ratio of a stock and includes a rolling median to help identify trends or central tendencies in valuation over time.

Key Features:
  • Quarterly EPS Data: Retrieves the diluted EPS for the most recent fiscal quarter (FQ) of the selected stock using financial data.
  • Annualized EPS: Quarterly EPS is multiplied by four to estimate annualized EPS, assuming consistent earnings throughout the year.
  • Forward P/E Calculation: The forward P/E is derived by dividing the stock's current closing price by its annualized EPS.
  • Median Forward P/E: A rolling median of the forward P/E ratio is calculated over a user-defined window (default: 14 periods) and plotted for trend analysis.
  • Visualization:
  • The Forward P/E ratio is plotted in blue.
  • The Median Forward P/E is plotted in orange for comparison and trend analysis.


Reference Line: An optional horizontal line at 0 helps identify anomalies, such as negative or invalid P/E values.

This enhanced tool is useful for investors and traders aiming to assess a stock's valuation trends and stability relative to its projected earnings, helping identify consistent overvaluation or undervaluation opportunities.
forecastingstatisticsValue

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明