OPEN-SOURCE SCRIPT
Forward P/E Rolling Z-Score

The Forward P/E Rolling Z-Score is an advanced fundamental-technical hybrid indicator designed to evaluate equity valuation extremes. By standardizing forward price-to-earnings (P/E) ratios into a rolling statistical Z-score, this tool helps investors identify when a stock or index is statistically overvalued or undervalued relative to its own historical baseline. Unlike traditional static P/E multiples that fail to account for shifting market regimes, this indicator dynamically measures standard deviation shifts over a rolling lookback period. Furthermore, it features a built-in historical performance tracker that automatically measures forward returns, win rates, and trigger counts across multiple time horizons (1-Month, 3-Month, 6-Month, and 1-Year) based on user-defined threshold crossings.
Key Features
Inputs & Customization
How to Use
Valuation Assessment: Monitor the lower pane oscillator. Values above +/- 2 indicate statistically expensive conditions, while values below your set threshold indicate attractive, cheap valuations.
Strategy Optimization: Use the on-chart performance table to inspect how historical signals have performed over various forward horizons to gauge the predictive edge of your chosen threshold.Disclaimer: This indicator is for educational and informational purposes only and does not constitute financial advice.
Key Features
- Dynamic Valuation Z-Score: Calculates a rolling mean and standard deviation of forward P/E ratios to measure statistical deviation from the norm.
- Optional Smoothing: Apply a moving average (SMA or EMA) to the raw Z-score to filter out high-frequency noise and reduce false signal whipsaws.
- Automated Performance Table: Displays a real-time analytics matrix on the chart tracking historical forward returns, win percentages, and total sample triggers since a customizable start date.
- Multi-Horizon Tracking: Evaluates signal efficacy across 4 distinct forward windows: 1 Month (21 bars), 3 Months (63 bars), 6 Months (126 bars), and 1 Year (252 bars).
[*]Visual Extremes Shading: Automatically highlights expensive and cheap valuation zones on the chart background for quick visual identification. - Flexible Signal Triggers: Customize your directional bias with selectable cross modes (Cross Over or Cross Under) and adjustable standard deviation thresholds.
Inputs & Customization
- Performance Tracking Start Date: Set the historical anchor date to begin tracking backtested signal performance.
- Z-Score Settings: Lookback Period (Bars) defines the historical window for mean and standard deviation calculations (default: 60); Signal Threshold & Direction defines the standard deviation trigger levels and whether to track crosses above or below the threshold; Annualize EPS automatically projects quarterly estimates into annualized figures.
- Moving Average Smoothing: Allows you to select between EMA or SMA, and adjust the length.
- Visuals: Toggle extreme zone background shading and select whether shading/signals rely on raw or smoothed Z-scores.
- Performance Table: Customize table placement (Top Right, Top Left, Bottom Right, Bottom Left) or toggle it entirely.
How to Use
Valuation Assessment: Monitor the lower pane oscillator. Values above +/- 2 indicate statistically expensive conditions, while values below your set threshold indicate attractive, cheap valuations.
Strategy Optimization: Use the on-chart performance table to inspect how historical signals have performed over various forward horizons to gauge the predictive edge of your chosen threshold.Disclaimer: This indicator is for educational and informational purposes only and does not constitute financial advice.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.