PROTECTED SOURCE SCRIPT
Cập nhật Ultimate Fundamental Fortress

Script Overview
This script provides a comprehensive Fundamental Health Scorecard for stocks, calculating a normalized score out of 100 based on key financial metrics fetched from TradingView's fundamental data. It displays the results in an elegant table with customizable colors, a dynamic plot for visualization, and a scorecard label for quick insights. The scorecard helps users assess a stock's value, profitability, and financial strength at a glance.
Purpose
The primary goal is to simplify fundamental analysis by aggregating essential ratios into a single, easy-to-interpret score. Inspired by value investing principles (e.g., low P/E and P/B for undervalued stocks, high ROE for efficiency), it empowers traders and investors to identify strong fundamentals quickly. It's especially useful for screening undervalued opportunities or comparing stocks within sectors.
Principles
Metrics Selection: Focuses on core fundamentals: Price-to-Book (P/B), Price-to-Earnings (P/E), Return on Equity (ROE), Debt-to-Equity (D/E), Free Cash Flow (FCF normalized by market cap), EBITDA (normalized by market cap), and Net Profit Margin. These are chosen for their balance of valuation, profitability, and risk assessment.
Scoring Philosophy: Each metric is scored based on thresholds (e.g., low ratios for valuation metrics indicate better value). If manual sector averages are provided, scoring becomes relative (e.g., stock P/B below sector average gets higher points), reducing subjectivity and adapting to industry norms. Without averages, absolute thresholds apply.
Normalization: Scores are summed and scaled to 100, ignoring missing data to ensure robustness. This allows fair comparison across stocks with varying data availability.
Customization: Users can adjust thresholds, colors, and sector averages for personalized analysis, making it flexible for different markets or strategies.
Calculation Methodology
Data Fetching: Uses request.financial() to pull quarterly (FQ) or trailing twelve months (TTM) data for metrics like BVPS, EPS, ROE, etc.
Ratio Computations:
P/B = Close Price / BVPS
P/E = Close Price / EPS
ROE = Directly fetched
D/E = Total Liabilities / Equity
Net Margin = Net Income / Revenue
Normalized FCF = FCF / Market Cap (as percentage)
Normalized EBITDA = EBITDA / Market Cap (as percentage)
Scoring:
For each metric, compare to thresholds or relative to sector averages (if provided >0).
Example for P/B: If relative (sector avg >0), stock P/B < avg * high factor → 15 pts; < avg * med factor → 10 pts; etc.
For ROE/Net Margin (higher is better): Reverse logic (stock > avg / factor).
FCF/EBITDA: Always absolute (normalized thresholds).
Minimum score per metric: 2-5 pts if poor.
Total Score: Sum valid scores, divide by max possible for those metrics, multiply by 100.
Output: Table shows components, values, scores, and sector avgs.
Plot visualizes score with color-coding.
Label categorizes (e.g., "Buffett Approved" for 85+).
User Inputs and Benefits
Thresholds (Absolute/Relative Factors): Customize scoring rules (e.g., change P/E low threshold from 10 to 12).
Benefit: Adapt to personal strategy or market conditions – e.g., stricter for growth stocks.
Manual Sector Averages: Enter averages (e.g., sector P/B = 2.5).
Benefit: Makes scoring industry-specific, reducing bias (e.g., tech's high P/E normal, banking's low ROE risky). If not entered (≤0), falls back to absolute for simplicity.
Color Customizations: Adjust table colors (header, scores).
Benefit: Personalize visuals for dark/light themes, improving readability and user experience.
Normalized FCF/EBITDA Thresholds: Set as % of market cap. Benefit: Size-independent comparison – small caps won't be disadvantaged.
Usage Notes Add to chart via Indicators menu.
Data relies on TradingView fundamentals – may be limited for some exchanges (e.g., BIST, international). Use manual averages for accuracy.
For screener: High request count (10) may exceed limits; use reduced version if needed.
Not financial advice – always verify with external sources.
Feedback welcome – let's improve together!
This script provides a comprehensive Fundamental Health Scorecard for stocks, calculating a normalized score out of 100 based on key financial metrics fetched from TradingView's fundamental data. It displays the results in an elegant table with customizable colors, a dynamic plot for visualization, and a scorecard label for quick insights. The scorecard helps users assess a stock's value, profitability, and financial strength at a glance.
Purpose
The primary goal is to simplify fundamental analysis by aggregating essential ratios into a single, easy-to-interpret score. Inspired by value investing principles (e.g., low P/E and P/B for undervalued stocks, high ROE for efficiency), it empowers traders and investors to identify strong fundamentals quickly. It's especially useful for screening undervalued opportunities or comparing stocks within sectors.
Principles
Metrics Selection: Focuses on core fundamentals: Price-to-Book (P/B), Price-to-Earnings (P/E), Return on Equity (ROE), Debt-to-Equity (D/E), Free Cash Flow (FCF normalized by market cap), EBITDA (normalized by market cap), and Net Profit Margin. These are chosen for their balance of valuation, profitability, and risk assessment.
Scoring Philosophy: Each metric is scored based on thresholds (e.g., low ratios for valuation metrics indicate better value). If manual sector averages are provided, scoring becomes relative (e.g., stock P/B below sector average gets higher points), reducing subjectivity and adapting to industry norms. Without averages, absolute thresholds apply.
Normalization: Scores are summed and scaled to 100, ignoring missing data to ensure robustness. This allows fair comparison across stocks with varying data availability.
Customization: Users can adjust thresholds, colors, and sector averages for personalized analysis, making it flexible for different markets or strategies.
Calculation Methodology
Data Fetching: Uses request.financial() to pull quarterly (FQ) or trailing twelve months (TTM) data for metrics like BVPS, EPS, ROE, etc.
Ratio Computations:
P/B = Close Price / BVPS
P/E = Close Price / EPS
ROE = Directly fetched
D/E = Total Liabilities / Equity
Net Margin = Net Income / Revenue
Normalized FCF = FCF / Market Cap (as percentage)
Normalized EBITDA = EBITDA / Market Cap (as percentage)
Scoring:
For each metric, compare to thresholds or relative to sector averages (if provided >0).
Example for P/B: If relative (sector avg >0), stock P/B < avg * high factor → 15 pts; < avg * med factor → 10 pts; etc.
For ROE/Net Margin (higher is better): Reverse logic (stock > avg / factor).
FCF/EBITDA: Always absolute (normalized thresholds).
Minimum score per metric: 2-5 pts if poor.
Total Score: Sum valid scores, divide by max possible for those metrics, multiply by 100.
Output: Table shows components, values, scores, and sector avgs.
Plot visualizes score with color-coding.
Label categorizes (e.g., "Buffett Approved" for 85+).
User Inputs and Benefits
Thresholds (Absolute/Relative Factors): Customize scoring rules (e.g., change P/E low threshold from 10 to 12).
Benefit: Adapt to personal strategy or market conditions – e.g., stricter for growth stocks.
Manual Sector Averages: Enter averages (e.g., sector P/B = 2.5).
Benefit: Makes scoring industry-specific, reducing bias (e.g., tech's high P/E normal, banking's low ROE risky). If not entered (≤0), falls back to absolute for simplicity.
Color Customizations: Adjust table colors (header, scores).
Benefit: Personalize visuals for dark/light themes, improving readability and user experience.
Normalized FCF/EBITDA Thresholds: Set as % of market cap. Benefit: Size-independent comparison – small caps won't be disadvantaged.
Usage Notes Add to chart via Indicators menu.
Data relies on TradingView fundamentals – may be limited for some exchanges (e.g., BIST, international). Use manual averages for accuracy.
For screener: High request count (10) may exceed limits; use reduced version if needed.
Not financial advice – always verify with external sources.
Feedback welcome – let's improve together!
Phát hành các Ghi chú
Update Notes for "Ultimate Fundamental Fortress" ScriptThank you for your interest in the "Ultimate Fundamental Fortress" script! This update brings significant enhancements based on user feedback and iterative improvements. The core goal was to make the script more flexible, user-friendly, and aligned with the investment philosophies of Warren Buffett (value investing with emphasis on quality and moat) and Peter Lynch (growth at a reasonable price with PEG focus). Below, I detail the key innovations, improvements, and their benefits.
Key Innovations and Additions:
Investment Style Modes (Buffett vs. Lynch): Added a dropdown to switch between Buffett mode (focus on low valuations, high ROE/FCF, and qualitative factors) and Lynch mode (growth-oriented with PEG emphasis). This allows users to tailor the screener to different strategies.
Data Period Selection (Quarterly/FY): Users can choose between recent quarter (FQ) or fiscal year (FY) data for financial metrics. TTM was removed due to data availability issues, ensuring more reliable results.
Qualitative Metrics (Economic Moat and Management Quality): Introduced manual inputs for moat rating (Wide/Narrow/None) and management score (0-10). These are weighted higher in Buffett mode (15+10 points) and lower in Lynch mode (5+5 points). An option to include/exclude them (include_qualitative) was added—if disabled, they have zero impact on scoring.
Input Grouping: Organized inputs into logical sections (e.g., "Style and Period Settings," "Sector Averages") for better usability in the settings panel.
Dynamic Table with Warning Row: The table now adjusts row count based on mode and options. A warning row appears for critical data missing (ROE, FCF, or PEG in Lynch), alerting users to verify from other sources.
Scoring Enhancements: Normalization ensures scores are always out of 100, even with missing data. Qualitative scores are tiered (e.g., Wide moat = full points). Color-coding in the table reflects performance levels.
Improvements and Optimizations:
Data Handling: Improved NaN checks and "NO DATA" displays for robustness. Removed TTM to avoid frequent data gaps, focusing on stable FQ/FY.
Mode-Specific Weights: Buffett mode boosts ROE/FCF/moat weights for value focus; Lynch boosts PEG for growth. This makes the script more faithful to each investor's style.
User Experience: Inputs are now grouped and positioned logically (qualitative right after period). Table is dynamic—qualitative rows only show if included.
Error Fixes: Added dynamic_requests=true to support conditional data fetches, resolving runtime errors.
Benefits:Flexibility: Users can customize for Buffett's long-term value or Lynch's GARP, with toggles for qualitative factors—ideal for blending quant and qual analysis.
Reliability: Fewer "NO DATA" issues with FQ/FY focus; warning row prevents misleading scores.
Usability: Grouped inputs reduce clutter; dynamic table keeps visualization clean. Normalization ensures fair scoring across modes.
Alignment with Philosophies: Buffett mode emphasizes moat/management (as in his letters); Lynch mode prioritizes PEG (from "One Up on Wall Street").
Performance: Code is modular and efficient, suitable for TradingView's limits—better for screener use.
This update elevates the script from a basic fundamental analyzer to a versatile tool for value/growth investing. If you have feedback, let me know!
Phát hành các Ghi chú
A multiplier error in the ROE calculation has been corrected.Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể tự do sử dụng tập lệnh mà không có bất kỳ hạn chế nào – tìm hiểu thêm tại đây.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể tự do sử dụng tập lệnh mà không có bất kỳ hạn chế nào – tìm hiểu thêm tại đây.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.