OPEN-SOURCE SCRIPT

Stock's Intrinsic Value| DCF model

Script Description
This pine script is based on a YouTube video titled: Warren Buffett: How to Calculate the Intrinsic Value of a Stock. Warren Buffett is a famous value investor who follows the principles of his mentor Benjamin Graham. He looks for companies that have strong competitive advantages, consistent earnings, and low debt. He also considers the intrinsic value of a company, which is the present value of its future cash flows, and compares it to the market price. He prefers to buy stocks that are trading below their intrinsic value and hold them for a long time.

One of the methods that Buffett uses to estimate the intrinsic value of a company is the discounted cash flow (DCF) model. This involves projecting the free cash flow (FCF) of the company for several years and then discounting it back to the present using an appropriate discount rate. The discount rate is usually the weighted average cost of capital (WACC) of the company, which reflects its cost of equity and debt. The sum of the discounted FCFs and terminal value is the intrinsic value of the company.

Lastly, a margin of safety is included when using the DCF method for stock valuation because of uncertainty and error in estimating future cash flows and the intrinsic value of the company.

When the current price is below margin of safety, it means that the stock is currently undervalued and being price at significantly below its intrinsic value.

Guideline for determining each variable in this script
FCF growth rate: This is the annual rate at which the free cash flow (FCF) of the company is expected to grow over a forecast 10-year period. You can use historical FCF growth rates, industry averages, analyst estimates, or your assumptions to project the FCF growth rate. The higher the FCF growth rate, the higher the intrinsic value will be.

Discount rate: This is the rate of return that you require to invest in the company. It reflects the risk and opportunity cost of investing in the company. You can use the weighted average cost of capital (WACC) of the company, capital pricing model (CAPM), hurdle rate, or market rate as the discount rate. The lower the discount rate, the higher the intrinsic value.

The margin of safety: Provides a cushion against errors in the valuation or adverse events that may affect the company. The margin of safety depends on your personal preference and risk tolerance. Normally is at 15% - 30%, the higher the margin of safety you set, the lower the chance that the stock will hit that level.

How to use this script
Step 1: This script only works for stocks that have financial data of free cash flow and total common shares outstanding
Step 2: Please use a yearly chart (12-month chart)
Step 3: You are required to determine a growth rate that will grow the free cash flow 10 years into the future
Step 4: You are required to determine a discount rate for the calculations
Step 5: You are required to add a margin of safety (Accounting for uncertainty)
Step 6: The rest of the calculations will be done automatically.

Disclaimer when using this script
  • I'm not a financial advisor
  • This script is for education purposes only
  • There are risks involved with stock market investing and investors should not act upon the content or information found here without first seeking advice from an accountant, financial planner, lawyer or other professional.
  • I can’t guarantee that this script will be error-free as I still consider myself a Pinescript beginner
  • Before making any decisions, investors should always research companies individually
  • I'll not be liable for any loss incurred, arising from the use of, or reliance on, this script


Limitations of this script
  • This script only works on the yearly chart (12 monthly charts)
  • The intrinsic value of a company will be negative if the company have a negative forecasted free cash flow
  • You need to make an educated guess about the growth rate, discount rate and margin of safety
  • This script uses free cash flow instead of owner's earnings (Operating cash flow - Maintenance capital expenditure), therefore it can't accurately estimate the maintenance capital expenditure.
  • Need at least 6 years’ worth of financial data
  • Market capitalisation uses total common shares outstanding multiplied by the closing price instead of using company-level total outstanding shares multiplied by the closing price

DCFeducationalforecastingFundamental Analysisintrinsicvaluevalueinvestingwarrenbuffet

Script de código abierto

Siguiendo fielmente el espíritu de TradingView, el autor de este script lo ha publicado en código abierto, permitiendo que otros traders puedan entenderlo y verificarlo. ¡Olé por el autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la reutilización de este código en la publicación se rige por las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

¿Quiere utilizar este script en un gráfico?

Exención de responsabilidad