TradingView
Thomas_Chia_Han_Yang
Dec 19, 2023 2:05 PM

Stock's Intrinsic Value| DCF model 

Apple Inc.NASDAQ

Description

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

Comments
RedKTrader
Best script i found for DCF.. thank you for your effort and for sharing here..
RedKTrader
just came back to say that i see an issue (bug?) when the chart is monthly in table (1) and in the Intrinsic value .. I suggest you separate the calculation from the chart TF .. (and debug the issue)
cause in reality, there should be no dependency on the chart's TF for running this calculation .. but i still commend the effort :)
Thomas_Chia_Han_Yang
@RedKTrader, Thanks for the advice and the coins. I'm still a beginner on Pine script. I will try my best to fix this issue :D
Dainosta
I've noticed that all other intrinsic value scripts use EPS ( which is most of the time overstated by managers), but your script uses FCF which is much better since it gives a better picture of a company's financial health.

Great work!
F-B_AutoPilot
I find your indicator fantastic, really good work, especially when you say that you are still a beginner in Pine Script. But your indicator is a masterpiece in terms of presentation, calculation, and customization options. You've won me over as a follower, keep up the good work! You really have the knack for it! I'm looking forward to seeing more from you!!! :)
Phantom_007
Why for some stocks, it shows negative value?
Thomas_Chia_Han_Yang
@Phantom_007, one of the limitations for this script is that if the forecasted free cash flow is negative, the intrinsic value will be negative as well.
vensonom
Any idea why this Intrinsic value is way off for NVDA ? it seems accurate for other tickers.
More